ParseSchema

Parse~ ParseSchema

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

All the schemas methods require MasterKey.

When adding fields, you may set required and default values. (Requires Parse Server 3.7.0+)

const options = { required: true, defaultValue: 'hello world' };
const schema = new Parse.Schema('MyClass');
schema.addString('field', options);
schema.addIndex('index_name', { 'field': 1 });
schema.save();

Constructor

new ParseSchema(className)

Parameters:
Name Type Description
className string

Parse Class string.

Methods

(static) all() → {Promise}

Static method to get all schemas

Returns:
Type:
Promise

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

addArray(name, options) → {Parse.Schema}

Adding Array Field

Parameters:
Name Type Description
name string

Name of the field that will be created on Parse

options object

See addField

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addBoolean(name, options) → {Parse.Schema}

Adding Boolean Field

Parameters:
Name Type Description
name string

Name of the field that will be created on Parse

options object

See addField

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addDate(name, options) → {Parse.Schema}

Adding Date Field

Parameters:
Name Type Description
name string

Name of the field that will be created on Parse

options object

See addField

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addField(name, type, options) → {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

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

options object

Valid options are:

  • required: If field is not set, save operation fails (Requires Parse Server 3.7.0+)
  • defaultValue: If field is not set, a default value is selected (Requires Parse Server 3.7.0+)
Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addFile(name, options) → {Parse.Schema}

Adding File Field

Parameters:
Name Type Description
name string

Name of the field that will be created on Parse

options object

See addField

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addGeoPoint(name, options) → {Parse.Schema}

Adding GeoPoint Field

Parameters:
Name Type Description
name string

Name of the field that will be created on Parse

options object

See addField

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

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

Adding an Index to Create / Update a Schema

Parameters:
Name Type Description
name string

Name of the index

index object

{ field: value }

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

schema.addIndex('index_name', { 'field': 1 });

addNumber(name, options) → {Parse.Schema}

Adding Number Field

Parameters:
Name Type Description
name string

Name of the field that will be created on Parse

options object

See addField

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addObject(name, options) → {Parse.Schema}

Adding Object Field

Parameters:
Name Type Description
name string

Name of the field that will be created on Parse

options object

See addField

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addPointer(name, targetClass, options) → {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

options object

See addField

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

addPolygon(name, options) → {Parse.Schema}

Adding Polygon Field

Parameters:
Name Type Description
name string

Name of the field that will be created on Parse

options object

See addField

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, options) → {Parse.Schema}

Adding String Field

Parameters:
Name Type Description
name string

Name of the field that will be created on Parse

options object

See addField

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

delete() → {Promise}

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

Returns:
Type:
Promise

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

deleteField(name) → {Parse.Schema}

Deleting a Field to Update on a Schema

Parameters:
Name Type Description
name string

Name of the field

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

deleteIndex(name) → {Parse.Schema}

Deleting an Index to Update on a Schema

Parameters:
Name Type Description
name string

Name of the field

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

get() → {Promise}

Get the Schema from Parse

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() → {Promise}

Create a new Schema on Parse

Returns:
Type:
Promise

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

setCLP(clp) → {Parse.Schema}

Sets Class Level Permissions when creating / updating a Schema. EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed

Parameters:
Name Type Description
clp object

Class Level Permissions

Returns:
Type:
Parse.Schema

Returns the schema, so you can chain this call.

update() → {Promise}

Update a Schema on Parse

Returns:
Type:
Promise

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