import ParseACL from './ParseACL';
import ParseError from './ParseError';
import ParseFile from './ParseFile';
import { Op } from './ParseOp';
import ParseRelation from './ParseRelation';
import type { AttributeMap, OpsMap } from './ObjectStateMutations';
import type { RequestOptions, FullOptions, BaseRequestOptions } from './RESTController';
import type ParseGeoPoint from './ParseGeoPoint';
import type ParsePolygon from './ParsePolygon';
export interface Pointer {
__type: string;
className: string;
objectId?: string;
_localId?: string;
}
interface SaveParams {
method: string;
path: string;
body: AttributeMap;
}
export interface SaveOptions extends BaseRequestOptions {
/** If `false`, nested objects will not be saved (default is `true`). */
cascadeSave?: boolean;
batchSize?: number;
transaction?: boolean;
}
export interface FetchOptions extends BaseRequestOptions {
include?: string | string[];
}
export interface SetOptions {
ignoreValidation?: boolean;
unset?: boolean;
}
export type DestroyOptions = BaseRequestOptions;
/** Options for destroyAll batch operation */
export interface DestroyAllOptions extends BaseRequestOptions {
/** batchSize: How many objects to yield in each batch (default: 20) */
batchSize?: number;
/** Set to true to enable transactions */
transaction?: boolean;
}
/** Options for saveAll batch operation */
export interface SaveAllOptions extends BaseRequestOptions {
/** batchSize: How many objects to yield in each batch (default: 20) */
batchSize?: number;
/** If `false`, nested objects will not be saved (default is `true`). */
cascadeSave?: boolean;
/** Set to true to enable transactions */
transaction?: boolean;
}
/** Options for fetchAll batch operation */
export interface FetchAllOptions extends BaseRequestOptions {
include?: string | string[];
}
export type AttributeKey You won't normally call this method directly. It is recommended that
* you use a subclass of However, if you don't want to use a subclass, or aren't sure which
* subclass is appropriate, you can use this form:Parse.Object instead, created by calling
* extend.
* var object = new Parse.Object("ClassName");
*
* That is basically equivalent to:
* var MyClass = Parse.Object.extend("ClassName");
* var object = new MyClass();
*
true if the attribute contains a value that is not
* null or undefined.
*
* @param {string} attr The string name of the attribute.
* @returns {boolean}
*/
hasYou can call it with an object containing keys and values, with one * key and value, or dot notation. For example:
* gameTurn.set({
* player: player1,
* diceRoll: 2
* }, {
* error: function(gameTurnAgain, error) {
* // The set failed validation.
* }
* });
*
* game.set("currentPlayer", player2, {
* error: function(gameTurnAgain, error) {
* // The set failed validation.
* }
* });
*
* game.set("finished", true);
*
* game.set("player.score", 10);
*
* @param {(string|object)} key The key to set.
* @param {(string|object)} value The value to give it.
* @param {object} options A set of options for the set.
* The only supported option is error.
* @returns {Parse.Object} Returns the object, so you can chain this call.
*/
setParse.Object, in which case you can override this method
* to provide additional validation on set and
* save. Your implementation should return
*
* @param {object} attrs The current data to validate.
* @returns {Parse.Error|boolean} False if the data is valid. An error object otherwise.
* @see Parse.Object#set
*/
validate(attrs: Attributes): ParseError | boolean;
/**
* Returns the ACL for this object.
*
* @returns {Parse.ACL|null} An instance of Parse.ACL.
* @see Parse.Object#get
*/
getACL(): ParseACL | null;
/**
* Sets the ACL to be used for this object.
*
* @param {Parse.ACL} acl An instance of Parse.ACL.
* @param {object} options
* @returns {Parse.Object} Returns the object, so you can chain this call.
* @see Parse.Object#set
*/
setACL(acl: ParseACL, options?: any): this;
/**
* Clears any (or specific) changes to this object made since the last call to save()
*
* @param {string} [keys] - specify which fields to revert
*/
revert(...keys: Extract
* object.save();
* or
* object.save(attrs);
* or
* object.save(null, options);
* or
* object.save(attrs, options);
* or
* object.save(key, value);
* or
* object.save(key, value, options);
*
* Example 1:
* gameTurn.save({
* player: "Jake Cutter",
* diceRoll: 2
* }).then(function(gameTurnAgain) {
* // The save was successful.
* }, function(error) {
* // The save failed. Error is an instance of Parse.Error.
* });
*
* Example 2:
* gameTurn.save("player", "Jake Cutter");
*
* @param {string | object | null} [arg1]
* Valid options are:
* await object.pin();
*
*
* To retrieve object:
* query.fromLocalDatastore() or query.fromPin()
*
* @returns {Promise} A promise that is fulfilled when the pin completes.
*/
pin(): Promise
* await object.unPin();
*
*
* @returns {Promise} A promise that is fulfilled when the unPin completes.
*/
unPin(): Promise
* const isPinned = await object.isPinned();
*
*
* @returns {Promise
* await object.pinWithName(name);
*
*
* To retrieve object:
* query.fromLocalDatastore() or query.fromPinWithName(name)
*
* @param {string} name Name of Pin.
* @returns {Promise} A promise that is fulfilled when the pin completes.
*/
pinWithName(name: string): Promise
* await object.unPinWithName(name);
*
*
* @param {string} name Name of Pin.
* @returns {Promise} A promise that is fulfilled when the unPin completes.
*/
unPinWithName(name: string): Promise
* await object.fetchFromLocalDatastore();
*
*
* You can create an unfetched pointer with Parse.Object.createWithoutData()
* and then call fetchFromLocalDatastore() on it.
*
* @returns {Promise} A promise that is fulfilled when the fetch completes.
*/
fetchFromLocalDatastore(): Promise
* Parse.Object.fetchAll([object1, object2, ...])
* .then((list) => {
* // All the objects were fetched.
* }, (error) => {
* // An error occurred while fetching one of the objects.
* });
*
*
* @param {Array} list A list of Parse.Object.
* @param {object} options
* Valid options are:
* Parse.Object.fetchAllWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
* .then((list) => {
* // All the objects were fetched.
* }, (error) => {
* // An error occurred while fetching one of the objects.
* });
*
*
* @param {Array} list A list of Parse.Object.
* @param {string | Array
* Parse.Object.fetchAllIfNeededWithInclude([object1, object2, ...], [pointer1, pointer2, ...])
* .then((list) => {
* // All the objects were fetched.
* }, (error) => {
* // An error occurred while fetching one of the objects.
* });
*
*
* @param {Array} list A list of Parse.Object.
* @param {string | Array
* Parse.Object.fetchAllIfNeeded([object1, ...])
* .then((list) => {
* // Objects were fetched and updated.
* }, (error) => {
* // An error occurred while fetching one of the objects.
* });
*
*
* @param {Array} list A list of Parse.Object.
* @param {object} options
* Valid options are:Unlike saveAll, if an error occurs while deleting an individual model, * this method will continue trying to delete the rest of the models if * possible, except in the case of a fatal error like a connection error. * *
In particular, the Parse.Error object returned in the case of error may * be one of two types: * *
* Parse.Object.destroyAll([object1, object2, ...])
* .then((list) => {
* // All the objects were deleted.
* }, (error) => {
* // An error occurred while deleting one or more of the objects.
* // If this is an aggregate error, then we can inspect each error
* // object individually to determine the reason why a particular
* // object was not deleted.
* if (error.code === Parse.Error.AGGREGATE_ERROR) {
* for (var i = 0; i < error.errors.length; i++) {
* console.log("Couldn't delete " + error.errors[i].object.id +
* "due to " + error.errors[i].message);
* }
* } else {
* console.log("Delete aborted because of " + error.message);
* }
* });
*
*
* @param {Array} list A list of Parse.Object.
* @param {object} options
* Valid options are:
* Parse.Object.saveAll([object1, object2, ...])
* .then((list) => {
* // All the objects were saved.
* }, (error) => {
* // An error occurred while saving one of the objects.
* });
*
*
* @param {Array} list A list of Parse.Object.
* @param {object} options
* Valid options are:
* A shortcut for:
* var Foo = Parse.Object.extend("Foo");
* var pointerToFoo = new Foo();
* pointerToFoo.id = "myObjectId";
*
*
* @param {string} id The ID of the object to create a reference to.
* @static
* @returns {Parse.Object} A Parse.Object reference.
*/
static createWithoutDataEvery extension of a Parse class will inherit from the most recent * previous extension of that class. When a Parse.Object is automatically * created by parsing JSON, it will use the most recent extension of that * class.
* *You should call either:
* var MyClass = Parse.Object.extend("MyClass", {
* Instance methods,
* initialize: function(attrs, options) {
* this.someInstanceProperty = [],
* Other instance properties
* }
* }, {
* Class properties
* });
* or, for Backbone compatibility:
* var MyClass = Parse.Object.extend({
* className: "MyClass",
* Instance methods,
* initialize: function(attrs, options) {
* this.someInstanceProperty = [],
* Other instance properties
* }
* }, {
* Class properties
* });
*
* @param {string} className The name of the Parse class backing this model.
* @param {object} [protoProps] Instance properties to add to instances of the
* class returned from this method.
* @param {object} [classProps] Class properties to add the class returned from
* this method.
* @returns {Parse.Object} A new subclass of Parse.Object.
*/
static extend(className: any, protoProps?: any, classProps?: any): any;
/**
* Enable single instance objects, where any local objects with the same Id
* share the same attributes, and stay synchronized with each other.
* This is disabled by default in server environments, since it can lead to
* security issues.
*
* @static
*/
static enableSingleInstance(): void;
/**
* Disable single instance objects, where any local objects with the same Id
* share the same attributes, and stay synchronized with each other.
* When disabled, you can have two instances of the same object in memory
* without them sharing attributes.
*
* @static
*/
static disableSingleInstance(): void;
/**
* Asynchronously stores the objects and every object they point to in the local datastore,
* recursively, using a default pin name: _default.
*
* If those other objects have not been fetched from Parse, they will not be stored.
* However, if they have changed data, all the changes will be retained.
*
*
* await Parse.Object.pinAll([...]);
*
*
* To retrieve object:
* query.fromLocalDatastore() or query.fromPin()
*
* @param {Array} objects A list of Parse.Object.
* @returns {Promise} A promise that is fulfilled when the pin completes.
* @static
*/
static pinAll(objects: ParseObject[]): Promise
* await Parse.Object.pinAllWithName(name, [obj1, obj2, ...]);
*
*
* To retrieve object:
* query.fromLocalDatastore() or query.fromPinWithName(name)
*
* @param {string} name Name of Pin.
* @param {Array} objects A list of Parse.Object.
* @returns {Promise} A promise that is fulfilled when the pin completes.
* @static
*/
static pinAllWithName(name: string, objects: ParseObject[]): Promise
* await Parse.Object.unPinAll([...]);
*
*
* @param {Array} objects A list of Parse.Object.
* @returns {Promise} A promise that is fulfilled when the unPin completes.
* @static
*/
static unPinAll(objects: ParseObject[]): Promise
* await Parse.Object.unPinAllWithName(name, [obj1, obj2, ...]);
*
*
* @param {string} name Name of Pin.
* @param {Array} objects A list of Parse.Object.
* @returns {Promise} A promise that is fulfilled when the unPin completes.
* @static
*/
static unPinAllWithName(name: string, objects: ParseObject[]): Promise
* await Parse.Object.unPinAllObjects();
*
*
* @returns {Promise} A promise that is fulfilled when the unPin completes.
* @static
*/
static unPinAllObjects(): Promise
* await Parse.Object.unPinAllObjectsWithName(name);
*
*
* @param {string} name Name of Pin.
* @returns {Promise} A promise that is fulfilled when the unPin completes.
* @static
*/
static unPinAllObjectsWithName(name: string): Promise