You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`Parse.Analytics` can even be used as a lightweight error tracker — simply invoke the following and you'll have access to an overview of the rate and frequency of errors, broken down by error code, in your application:
How to best retrieve the file contents back depends on the context of your application. Because of cross-domain request issues, it's best if you can make the browser do the work for you. Typically, that means rendering the file's URL into the DOM. Here we render an uploaded profile photo on a page with jQuery:
Copy file name to clipboardExpand all lines: _includes/js/geopoints.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Parse allows you to associate real-world latitude and longitude coordinates with
7
7
To associate a point with an object you first need to create a `Parse.GeoPoint`. For example, to create a point with latitude of 40.0 degrees and -30.0 degrees longitude:
8
8
9
9
```javascript
10
-
var point =newParse.GeoPoint({latitude:40.0, longitude:-30.0});
It's also possible to query for the set of objects that are contained within a particular area. To find the objects in a rectangular bounding box, add the `withinGeoBox` restriction to your `Parse.Query`.
68
68
69
69
```javascript
70
-
var southwestOfSF =newParse.GeoPoint(37.708813, -122.526398);
71
-
var northeastOfSF =newParse.GeoPoint(37.822802, -122.373962);
Copy file name to clipboardExpand all lines: _includes/js/objects.md
+51-51Lines changed: 51 additions & 51 deletions
Original file line number
Diff line number
Diff line change
@@ -18,13 +18,13 @@ To create a new subclass, use the `Parse.Object.extend` method. Any `Parse.Quer
18
18
19
19
```javascript
20
20
// Simple syntax to create a new subclass of Parse.Object.
21
-
var GameScore =Parse.Object.extend("GameScore");
21
+
constGameScore=Parse.Object.extend("GameScore");
22
22
23
23
// Create a new instance of that class.
24
-
var gameScore =newGameScore();
24
+
constgameScore=newGameScore();
25
25
26
26
// Alternatively, you can use the typical Backbone syntax.
27
-
var Achievement =Parse.Object.extend({
27
+
constAchievement=Parse.Object.extend({
28
28
className:"Achievement"
29
29
});
30
30
```
@@ -34,7 +34,7 @@ You can add additional methods and properties to your subclasses of `Parse.Objec
34
34
```javascript
35
35
36
36
// A complex subclass of Parse.Object
37
-
var Monster =Parse.Object.extend("Monster", {
37
+
constMonster=Parse.Object.extend("Monster", {
38
38
// Instance methods
39
39
hasSuperHumanStrength:function () {
40
40
returnthis.get("strength") >18;
@@ -46,13 +46,13 @@ var Monster = Parse.Object.extend("Monster", {
46
46
}, {
47
47
// Class methods
48
48
spawn:function(strength) {
49
-
var monster =newMonster();
49
+
constmonster=newMonster();
50
50
monster.set("strength", strength);
51
51
return monster;
52
52
}
53
53
});
54
54
55
-
var monster =Monster.spawn(200);
55
+
constmonster=Monster.spawn(200);
56
56
alert(monster.get('strength')); // Displays 200.
57
57
alert(monster.sound); // Displays Rawr.
58
58
```
@@ -75,7 +75,7 @@ class Monster extends Parse.Object {
75
75
}
76
76
77
77
staticspawn(strength) {
78
-
var monster =newMonster();
78
+
constmonster=newMonster();
79
79
monster.set('strength', strength);
80
80
return monster;
81
81
}
@@ -156,8 +156,8 @@ There are also a few fields you don't need to specify that are provided as a con
156
156
If you prefer, you can set attributes directly in your call to `save` instead.
157
157
158
158
```javascript
159
-
var GameScore =Parse.Object.extend("GameScore");
160
-
var gameScore =newGameScore();
159
+
constGameScore=Parse.Object.extend("GameScore");
160
+
constgameScore=newGameScore();
161
161
162
162
gameScore.save({
163
163
score:1337,
@@ -176,22 +176,22 @@ gameScore.save({
176
176
You may add a `Parse.Object` as the value of a property in another `Parse.Object`. By default, when you call `save()` on the parent object, all nested objects will be created and/or saved as well in a batch operation. This feature makes it really easy to manage relational data as you don't have to take care of creating the objects in any specific order.
177
177
178
178
```javascript
179
-
var Child =Parse.Object.extend("Child");
180
-
var child =newChild();
179
+
constChild=Parse.Object.extend("Child");
180
+
constchild=newChild();
181
181
182
-
var Parent =Parse.Object.extend("Parent");
183
-
var parent =newParent();
182
+
constParent=Parse.Object.extend("Parent");
183
+
constparent=newParent();
184
184
185
-
parent.save({child: child});
185
+
parent.save({child: child});
186
186
// Automatically the object Child is created on the server
187
187
// just before saving the Parent
188
188
```
189
189
190
190
In some scenarios, you may want to prevent this default chain save. For example, when saving a team member's profile that points to an account owned by another user to which you don't have write access. In this case, setting the option `cascadeSave` to `false` may be useful:
191
191
192
192
```javascript
193
-
var TeamMember =Parse.Object.extend("TeamMember");
You may pass a `context` dictionary that is accessible in Cloud Code `beforeSave` and `afterSave` triggers for that `Parse.Object`. This is useful if you want to condition certain operations in Cloud Code triggers on ephemeral information that should not be saved with the `Parse.Object` in the database. The context is ephemeral in the sense that it vanishes after the Cloud Code triggers for that particular `Parse.Object` have executed. For example:
207
207
208
208
```javascript
209
-
var TeamMember =Parse.Object.extend("TeamMember");
Saving data to the cloud is fun, but it's even more fun to get that data out again. If the `Parse.Object` has been uploaded to the server, you can use the `objectId` to get it using a `Parse.Query`:
231
231
232
232
```javascript
233
-
var GameScore =Parse.Object.extend("GameScore");
234
-
var query =newParse.Query(GameScore);
233
+
constGameScore=Parse.Object.extend("GameScore");
234
+
constquery=newParse.Query(GameScore);
235
235
query.get("xWMyZ4YEGZ")
236
236
.then((gameScore) => {
237
237
// The object was retrieved successfully.
@@ -244,9 +244,9 @@ query.get("xWMyZ4YEGZ")
244
244
To get the values out of the `Parse.Object`, use the `get` method.
245
245
246
246
```javascript
247
-
var score =gameScore.get("score");
248
-
var playerName =gameScore.get("playerName");
249
-
var cheatMode =gameScore.get("cheatMode");
247
+
constscore=gameScore.get("score");
248
+
constplayerName=gameScore.get("playerName");
249
+
constcheatMode=gameScore.get("cheatMode");
250
250
```
251
251
252
252
Alternatively, the `attributes` property of the `Parse.Object` can be treated as a Javascript object, and even destructured.
The four special reserved values are provided as properties and cannot be retrieved using the 'get' method nor modified with the 'set' method:
259
259
260
260
```javascript
261
-
var objectId =gameScore.id;
262
-
var updatedAt =gameScore.updatedAt;
263
-
var createdAt =gameScore.createdAt;
264
-
var acl =gameScore.getACL();
261
+
constobjectId=gameScore.id;
262
+
constupdatedAt=gameScore.updatedAt;
263
+
constcreatedAt=gameScore.createdAt;
264
+
constacl=gameScore.getACL();
265
265
```
266
266
267
267
If you need to refresh an object you already have with the latest data that
@@ -290,8 +290,8 @@ Updating an object is simple. Just set some new data on it and call the save met
290
290
291
291
```javascript
292
292
// Create the object.
293
-
var GameScore =Parse.Object.extend("GameScore");
294
-
var gameScore =newGameScore();
293
+
constGameScore=Parse.Object.extend("GameScore");
294
+
constgameScore=newGameScore();
295
295
296
296
gameScore.set("score", 1337);
297
297
gameScore.set("playerName", "Sean Plott");
@@ -378,16 +378,16 @@ To create a new `Post` with a single `Comment`, you could write:
378
378
379
379
```javascript
380
380
// Declare the types.
381
-
var Post =Parse.Object.extend("Post");
382
-
varComment=Parse.Object.extend("Comment");
381
+
constPost=Parse.Object.extend("Post");
382
+
constComment=Parse.Object.extend("Comment");
383
383
384
384
// Create the post
385
-
var myPost =newPost();
385
+
constmyPost=newPost();
386
386
myPost.set("title", "I'm Hungry");
387
387
myPost.set("content", "Where should we go for lunch?");
388
388
389
389
// Create the comment
390
-
var myComment =newComment();
390
+
constmyComment=newComment();
391
391
myComment.set("content", "Let's do Sushirrito.");
392
392
393
393
// Add the post as a value in the comment
@@ -400,7 +400,7 @@ myComment.save();
400
400
Internally, the Parse framework will store the referred-to object in just one place, to maintain consistency. You can also link objects using just their `objectId`s like so:
401
401
402
402
```javascript
403
-
var post =newPost();
403
+
constpost=newPost();
404
404
post.id="1zEcyElZ80";
405
405
406
406
myComment.set("parent", post);
@@ -419,8 +419,8 @@ const title = post.get("title");
419
419
Many-to-many relationships are modeled using `Parse.Relation`. This works similar to storing an array of `Parse.Object`s in a key, except that you don't need to fetch all of the objects in a relation at once. In addition, this allows `Parse.Relation` to scale to many more objects than the array of `Parse.Object` approach. For example, a `User` may have many `Posts` that she might like. In this case, you can store the set of `Posts` that a `User` likes using `relation`. In order to add a `Post` to the "likes" list of the `User`, you can do:
420
420
421
421
```javascript
422
-
var user =Parse.User.current();
423
-
var relation =user.relation("likes");
422
+
constuser=Parse.User.current();
423
+
constrelation=user.relation("likes");
424
424
relation.add(post);
425
425
user.save();
426
426
```
@@ -460,7 +460,7 @@ relation.query().find({
460
460
If you want only a subset of the Posts, you can add extra constraints to the `Parse.Query` returned by query like this:
461
461
462
462
```javascript
463
-
var query =relation.query();
463
+
constquery=relation.query();
464
464
query.equalTo("title", "I'm Hungry");
465
465
query.find({
466
466
success:function(list) {
@@ -489,16 +489,16 @@ So far we've used values with type `String`, `Number`, and `Parse.Object`. Parse
489
489
Some examples:
490
490
491
491
```javascript
492
-
var number =42;
493
-
var bool =false;
494
-
var string ="the number is "+ number;
495
-
var date =newDate();
496
-
var array = [string, number];
497
-
var object = { number: number, string: string };
498
-
var pointer =MyClassName.createWithoutData(objectId);
0 commit comments