Schema

Parse. Schema

A Parse.Schema object is for handling schema data from Parse.

All the schemas methods require MasterKey.

const schema = new Parse.Schema('MyClass');
schema.addString('field');
schema.addIndex('index_name', {'field', 1});
schema.save();

Constructor

new Schema(className)

Parameters:
Name Type Description
className String

Parse Class string.

Methods

(static) all(options) → {Promise}

Static method to get all schemas

Parameters:
Name Type Description
options Object

Valid options are:

  • useMasterKey: In Cloud Code and Node only, causes the Master Key to be used for this request.
  • sessionToken: A valid session token, used for making a request on behalf of a specific user.

Returns:
Type:
Promise

A promise that is resolved with the result when the query completes.

addArray(name) → {Parse.Schema}

Adding Array Field

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addBoolean(name) → {Parse.Schema}

Adding Boolean Field

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addDate(name) → {Parse.Schema}

Adding Date Field

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addField(name, type) → {Parse.Schema}

Adding a Field to Create / Update a Schema

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

type String

TheCan be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation)

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addFile(name) → {Parse.Schema}

Adding File Field

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addGeoPoint(name) → {Parse.Schema}

Adding GeoPoint Field

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addIndex(name, type) → {Parse.Schema}

Adding an Index to Create / Update a Schema

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

type String

Can be a (String|Number|Boolean|Date|Parse.File|Parse.GeoPoint|Array|Object|Pointer|Parse.Relation)

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addNumber(name) → {Parse.Schema}

Adding Number Field

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addObject(name) → {Parse.Schema}

Adding Object Field

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addPointer(name, targetClass) → {Parse.Schema}

Adding Pointer Field

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

targetClass String

Name of the target Pointer Class

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addPolygon(name) → {Parse.Schema}

Adding Polygon Field

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addRelation(name, targetClass) → {Parse.Schema}

Adding Relation Field

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

targetClass String

Name of the target Pointer Class

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addString(name) → {Parse.Schema}

Adding String Field

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

delete(options) → {Promise}

Removing a Schema from Parse Can only be used on Schema without objects

Parameters:
Name Type Description
options Object

Valid options are:

  • useMasterKey: In Cloud Code and Node only, causes the Master Key to be used for this request.
  • sessionToken: A valid session token, used for making a request on behalf of a specific user.

Returns:
Type:
Promise

A promise that is resolved with the result when the query completes.

deleteField(name, targetClass) → {Parse.Schema}

Deleting a Field to Update on a Schema

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

targetClass String

Name of the target Pointer Class

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

deleteIndex(name, targetClass) → {Parse.Schema}

Deleting an Index to Update on a Schema

Parameters:
Name Type Description
name String

Name of the field that will be created on Parse

targetClass String

Name of the target Pointer Class

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

get(options) → {Promise}

Get the Schema from Parse

Parameters:
Name Type Description
options Object

Valid options are:

  • useMasterKey: In Cloud Code and Node only, causes the Master Key to be used for this request.
  • sessionToken: A valid session token, used for making a request on behalf of a specific user.

Returns:
Type:
Promise

A promise that is resolved with the result when the query completes.

purge() → {Promise}

Removes all objects from a Schema (class) in Parse. EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed

Returns:
Type:
Promise

A promise that is resolved with the result when the query completes.

save(options) → {Promise}

Create a new Schema on Parse

Parameters:
Name Type Description
options Object

Valid options are:

  • useMasterKey: In Cloud Code and Node only, causes the Master Key to be used for this request.
  • sessionToken: A valid session token, used for making a request on behalf of a specific user.

Returns:
Type:
Promise

A promise that is resolved with the result when the query completes.

update(options) → {Promise}

Update a Schema on Parse

Parameters:
Name Type Description
options Object

Valid options are:

  • useMasterKey: In Cloud Code and Node only, causes the Master Key to be used for this request.
  • sessionToken: A valid session token, used for making a request on behalf of a specific user.

Returns:
Type:
Promise

A promise that is resolved with the result when the query completes.