From 0c86bc02f8f29006c0767e204cf14d75eaec3975 Mon Sep 17 00:00:00 2001 From: "Raschid J.F. Rafeally" <8172495+RaschidJFR@users.noreply.github.com> Date: Sun, 28 Jul 2019 10:26:38 -0500 Subject: [PATCH] Add `keys` and `excludeKeys` options to REST docs (#649) * Add `keys` and `excludeKeys` options to REST docs * Add `.exclude()` example to JS Guide Added example of Query.exclude() in `js/queries.md` Closes #632 * Moved `keys` and `excludeKeys` from objects.md to queries.md Also: * Added `excludKeys` to the parameter table * Added padding to elements in `_normalize.scss` * Fix typo --- _includes/js/queries.md | 14 +++++++++- _includes/rest/objects.md | 4 ++- _includes/rest/queries.md | 44 ++++++++++++++++++++++++------- css/lib/multisite/_normalize.scss | 15 +++++++---- 4 files changed, 61 insertions(+), 16 deletions(-) diff --git a/_includes/js/queries.md b/_includes/js/queries.md index 1ddbf73f0..afc29383c 100644 --- a/_includes/js/queries.md +++ b/_includes/js/queries.md @@ -57,7 +57,7 @@ You can skip the first results by setting `skip`. In the old Parse hosted backen query.skip(10); // skip the first 10 results ``` -If you want to know the total number of rows in a table satisfying your query, for e.g. pagination purposes - you can use `withCount`. +If you want to know the total number of rows in a table satisfying your query, for e.g. pagination purposes - you can use `withCount`. **Note:** Enabling this flag will change the structure of response, see the example below. @@ -176,6 +176,18 @@ query.find().then(function(results) { }); ``` +Similarly, use `exclude` to remove undesired fields while retrieving the rest: + +```javascript +var GameScore = Parse.Object.extend("GameScore"); +var query = new Parse.Query(GameScore); +query.exclude("playerName"); +query.find().then(function(results) { + // Now each result will have all fields except `playerName` +}); +``` + + The remaining fields can be fetched later by calling `fetch` on the returned objects: ```javascript diff --git a/_includes/rest/objects.md b/_includes/rest/objects.md index ba613d753..737d02344 100644 --- a/_includes/rest/objects.md +++ b/_includes/rest/objects.md @@ -140,7 +140,7 @@ The response body is a JSON object containing all the user-provided fields, plus } ``` -When retrieving objects that have pointers to children, you can fetch child objects by using the `include` option. For instance, to fetch the object pointed to by the "game" key: +When retrieving objects that have pointers to children, **you can fetch child objects** by using the `include` option. For instance, to fetch the object pointed to by the "game" key:

@@ -192,6 +192,8 @@ print result
 
+ + ## Updating Objects To change the data on an object that already exists, send a PUT request to the object URL. Any keys you don't specify will remain unchanged, so you can update just a subset of the object's data. For example, if we wanted to change the score field of our object: diff --git a/_includes/rest/queries.md b/_includes/rest/queries.md index 912444c8a..a2acbb84c 100644 --- a/_includes/rest/queries.md +++ b/_includes/rest/queries.md @@ -302,13 +302,14 @@ print result In addition to `where`, there are several parameters you can use to configure what types of results are returned by the query. -| Parameter | Use | -|-----------------------------------------------------------------| -| order | Specify a field to sort by | -| limit | Limit the number of objects returned by the query | -| skip | Use with limit to paginate through results | -| keys | Restrict the fields returned by the query | -| include | Use on Pointer columns to return the full object | +| Parameter | Use | +|-------------------------------------------------------------------| +| order | Specify a field to sort by | +| limit | Limit the number of objects returned by the query | +| skip | Use with limit to paginate through results | +| keys | Restrict the fields returned by the query | +| excludeKeys | Exclude specific fields from the returned query | +| include | Use on Pointer columns to return the full object | You can use the `order` parameter to specify a field to sort by. Prefixing with a negative sign reverses the order. Thus, to retrieve scores in ascending order: @@ -411,7 +412,7 @@ print result -You can restrict the fields returned by passing `keys` a comma-separated list. To retrieve documents that contain only the `score` and `playerName` fields (and also special built-in fields such as `objectId`, `createdAt`, and `updatedAt`): +You can restrict the fields returned by passing `keys` or `excludeKeys` a comma-separated list. To retrieve documents that contain only the `score` and `playerName` fields (and also special built-in fields such as `objectId`, `createdAt`, and `updatedAt`):

@@ -436,6 +437,31 @@ print result
 
+Or you may use `excludeKeys` to fetch everything except `playerName`: + +
+

+curl -X GET \
+  -H "X-Parse-Application-Id: ${APPLICATION_ID}" \
+  -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
+  -G \
+  --data-urlencode 'excludeKeys=playerName' \
+  https://YOUR.PARSE-SERVER.HERE/parse/classes/GameScore/Ed1nuqPvcm
+
+

+import json,httplib,urllib
+connection = httplib.HTTPSConnection('YOUR.PARSE-SERVER.HERE', 443)
+params = urllib.urlencode({"excludeKeys":"playerName"})
+connection.connect()
+connection.request('GET', '/parse/classes/GameScore/Ed1nuqPvcm?%s' % params, '', {
+       "X-Parse-Application-Id": "${APPLICATION_ID}",
+       "X-Parse-REST-API-Key": "${REST_API_KEY}"
+     })
+result = json.loads(connection.getresponse().read())
+print result
+
+
+ All of these parameters can be used in combination with each other. For example:
@@ -1204,4 +1230,4 @@ connection.request('GET', '/parse/ -
\ No newline at end of file + diff --git a/css/lib/multisite/_normalize.scss b/css/lib/multisite/_normalize.scss index e62767358..43cca458d 100644 --- a/css/lib/multisite/_normalize.scss +++ b/css/lib/multisite/_normalize.scss @@ -273,10 +273,10 @@ button, input, select, textarea { - font-size: 100%; - margin: 0; - vertical-align: baseline; - *vertical-align: middle; + font-size: 100%; + margin: 0; + vertical-align: baseline; + *vertical-align: middle; } button, @@ -295,7 +295,7 @@ input[type="reset"], input[type="submit"] { -webkit-appearance: button; cursor: pointer; - *overflow: visible; + *overflow: visible; } button[disabled], @@ -342,3 +342,8 @@ table { border-collapse: collapse; border-spacing: 0; } + +td { + padding-left: 12px; + padding-right: 12px; +}