Skip to content

Commit c34d679

Browse files
committed
docs: AV.Object.query
1 parent 8374093 commit c34d679

File tree

1 file changed

+50
-43
lines changed

1 file changed

+50
-43
lines changed

src/object.js

Lines changed: 50 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ module.exports = function(AV) {
104104
* Saves the given list of AV.Object.
105105
* If any error is encountered, stops and calls the error handler.
106106
*
107-
* <pre>
108-
* AV.Object.saveAll([object1, object2, ...]).then(function(list) {
109-
* // All the objects were saved.
110-
* }, function(error) {
111-
* // An error occurred while saving one of the objects.
112-
* });
107+
* @example
108+
* AV.Object.saveAll([object1, object2, ...]).then(function(list) {
109+
* // All the objects were saved.
110+
* }, function(error) {
111+
* // An error occurred while saving one of the objects.
112+
* });
113113
*
114114
* @param {Array} list A list of <code>AV.Object</code>.
115115
*/
@@ -602,23 +602,25 @@ module.exports = function(AV) {
602602
* <code>"change"</code> unless you choose to silence it.
603603
*
604604
* <p>You can call it with an object containing keys and values, or with one
605-
* key and value. For example:<pre>
606-
* gameTurn.set({
607-
* player: player1,
608-
* diceRoll: 2
609-
* }, {
610-
* error: function(gameTurnAgain, error) {
611-
* // The set failed validation.
612-
* }
613-
* });
605+
* key and value. For example:</p>
614606
*
615-
* game.set("currentPlayer", player2, {
616-
* error: function(gameTurnAgain, error) {
617-
* // The set failed validation.
618-
* }
619-
* });
607+
* @example
608+
* gameTurn.set({
609+
* player: player1,
610+
* diceRoll: 2
611+
* }, {
612+
* error: function(gameTurnAgain, error) {
613+
* // The set failed validation.
614+
* }
615+
* });
620616
*
621-
* game.set("finished", true);</pre></p>
617+
* game.set("currentPlayer", player2, {
618+
* error: function(gameTurnAgain, error) {
619+
* // The set failed validation.
620+
* }
621+
* });
622+
*
623+
* game.set("finished", true);
622624
*
623625
* @param {String} key The key to set.
624626
* @param {Any} value The value to give it.
@@ -865,15 +867,16 @@ module.exports = function(AV) {
865867
* or<pre>
866868
* object.save(key, value, options);</pre>
867869
*
868-
* For example, <pre>
869-
* gameTurn.save({
870-
* player: "Jake Cutter",
871-
* diceRoll: 2
872-
* }).then(function(gameTurnAgain) {
873-
* // The save was successful.
874-
* }, function(error) {
875-
* // The save failed. Error is an instance of AVError.
876-
* });</pre>
870+
* @example
871+
* gameTurn.save({
872+
* player: "Jake Cutter",
873+
* diceRoll: 2
874+
* }).then(function(gameTurnAgain) {
875+
* // The save was successful.
876+
* }, function(error) {
877+
* // The save failed. Error is an instance of AVError.
878+
* });
879+
*
877880
* @param {AuthOptions} options AuthOptions plus:
878881
* @param {Boolean} options.fetchWhenSave fetch and update object after save succeeded
879882
* @param {AV.Query} options.query Save object only when it matches the query
@@ -1349,19 +1352,12 @@ module.exports = function(AV) {
13491352
* created by parsing JSON, it will use the most recent extension of that
13501353
* class.</p>
13511354
*
1352-
* <p>You should call either:<pre>
1353-
* var MyClass = AV.Object.extend("MyClass", {
1354-
* <i>Instance properties</i>
1355-
* }, {
1356-
* <i>Class properties</i>
1357-
* });</pre>
1358-
* or, for Backbone compatibility:<pre>
1359-
* var MyClass = AV.Object.extend({
1360-
* className: "MyClass",
1361-
* <i>Other instance properties</i>
1362-
* }, {
1363-
* <i>Class properties</i>
1364-
* });</pre></p>
1355+
* @example
1356+
* var MyClass = AV.Object.extend("MyClass", {
1357+
* // Instance properties
1358+
* }, {
1359+
* // Class properties
1360+
* });
13651361
*
13661362
* @param {String} className The name of the AV class backing this model.
13671363
* @param {Object} protoProps Instance properties to add to instances of the
@@ -1453,6 +1449,17 @@ module.exports = function(AV) {
14531449
AV.Object._classMap[className] = klass;
14541450
};
14551451

1452+
/**
1453+
* Get a new Query of the current class
1454+
* @name query
1455+
* @memberof AV.Object
1456+
* @type AV.Query
1457+
* @readonly
1458+
* @since v3.1.0
1459+
* @example
1460+
* const Post = AV.Object.extend('Post');
1461+
* Post.query.equalTo('author', 'leancloud').find().then();
1462+
*/
14561463
Object.defineProperty(AV.Object, 'query', {
14571464
get() {
14581465
return new AV.Query(this.prototype.className);

0 commit comments

Comments
 (0)