parse-utils

2.12.1 • Public • Published

parse-utils

Parse JS SDK and Parse-Server utilities


Setup

This library is available on npm, install it with: npm install --save parse-utils

API

setParseLib(parseLib)

Set the Parse library to use (node/react-native).

initializeParseSDK(serverURL, appId, masterKey)

Initialize the Parse SDK.

createPointerFromId(className, objectId)ParseObject

Create a pointer to a Parse object given its id and the class name

getObjectWithoutParseAttributes(object)
Object

Strip off the Parse specific attributes from an Object

setField(parseObject, fieldName, fieldValue)

Set the value of Parse object field (it mutates the object).

setPointer(parseObject, fieldName, pointerId, pointerClassName)

Set the value of Parse object field to a Parse pointer (it mutates the object).

setArrayOfPointers(parseObject, fieldName, pointersIds, pointersClassName)

Set the value of Parse object field to an array of pointers (it mutates the object).

uploadFile(fileName, file)ParseObject

Upload a file.

getUserByEmail(userEmail)ParseObject

Get a User given its email.

getUserById(userId)ParseObject

Get a User given its id.

getRoleByName(roleName)ParseObject

Get a Role given its name.

findAll(parseQuery, findOptions)Array.<ParseObject>

Execute a "find" Parse Query regardless of the limit imposed by Parse (which is 500).

saveAllInChunks(parseObjects, saveOptions, chunkSize)Array.<ParseObject>

Execute a "saveAll" Parse Query splitting in chunks the saveAll instructions.

createRoleIfNotExists(roleName, saveOptions)ParseObject

Create a Role with the specified name (only if it doesn't alrady exists).

isUserInRole(userId, roleName)Bool

Check if the the user is in a certain role.

loadClassesFromSchemas(parseServerDb, schemas, shouldUpdate)

Given an array of schemas of classes loads them in Parse Server.

setParseLib

Set the Parse library to use (node/react-native).

Category: Synchronous.

Param Type Description
parseLib Object The Parse library instance.

initializeParseSDK

Initialize the Parse SDK.

Category: Synchronous.

Param Type
serverURL String
appId String
masterKey String

createPointerFromId ⇒ ParseObject

Create a pointer to a Parse object given its id and the class name.

Returns: ParseObject - Pointer to the Parse object.
Category: Synchronous.

Param Type Description
className String The class name of the Parse object.
objectId String The id of the Parse object.

getObjectWithoutParseAttributes ⇒ Object

Strip off the Parse specific attributes from an Object.

Returns: Object - Object without the Parse specific attributes. Category: Synchronous.

Param Type Description
object Object Plain Javascript representation of a Parse Object.

setField

Set the value of Parse object field (it mutates the object).

Category: Synchronous.

Param Type Description
parseObject ParseObject The Parse object with the field that must be set.
fieldName String The name of the field.
fieldValue Number,Boolean,String,Array,ParseObject The value of the field.

setPointer

Set the value of Parse object field to a Parse pointer (it mutates the object).

Category: Synchronous.

Param Type Description
parseObject ParseObject The Parse object with the field that must be set.
fieldName String The name of the field.
pointerId String The objectId of the object pointed by the Parse pointer.
pointerClassName String The class name of the pointed object.

setArrayOfPointers

Set the value of Parse object field to an array of pointers (it mutates the object).

Category: Synchronous.

Param Type Description
parseObject ParseObject The object that with field that must be set.
fieldName String The name of the field
pointersIds Array.<String> The objectIds of the objects pointed by the Parse pointers.
pointersClassName String The class name of the pointed objects.

uploadFile ⇒ ParseObject

Upload a file.

Returns: ParseObject - The uploaded file.
Category: Asynchronous.

Param Type
fileName String
file File

getUserByEmail ⇒ ParseObject

Get a User given its email.

Returns: ParseObject - The User object.
Category: Asynchronous.

Param Type
userEmail String

getUserById ⇒ ParseObject

Get a User given its id.

Returns: ParseObject - The User object.
Category: Asynchronous.

Param Type
objectId String

getRoleByName ⇒ ParseObject

Get a Role given its name.

Returns: ParseObject - The Role object.
Category: Asynchronous.

Param Type
roleName String

findAll ⇒ Array.<ParseObject>

Execute a "find" Parse Query regardless of the limit imposed by Parse (which is 500).

Returns: Array.<ParseObject> - The array with the found Parse objects.
Category: Asynchronous.

Param Type Description
parseQuery ParseQuery The "find" Parse Query that will be executed.
findOptions Object Options passed to the "find" function.

saveAllInChunks ⇒ Array.<ParseObject>

Execute a "saveAll" Parse Query splitting in chunks the saveAll instructions.

Returns: Array.<ParseObject> - An array with the saved Parse Objects Category: Asynchronous.

Param Type Description
parseObjects Array.<ParseObject> The array of Parse object that will be saved.
saveOptions Object Options passed to the "saveAll" function.
chunkSize Number The chunk size of the promises.

createRoleIfNotExists ⇒ ParseObject

Create a Role with the specified name (only if it doesn't alrady exists).

Returns: ParseObject - The created Role (undefined if the role already exists).
Category: Asynchronous.

Param Type Description
roleName String The Role name.
saveOptions Object Options passed to the "save" command.

isUserInRole ⇒ Boolean

Check if the the user is in a certain role.

Returns: Boolean - Is the user in the role? Category: Asynchronous.

Param Type Description
userId String The user objectId.
roleName String The role name.

loadClassesFromSchemas

Given an array of schemas of classes loads them in Parse Server

Category: Asynchronous.

Param Type Description
parseServerDb Object The Parse Server DB instance.
schemas Array Array of schemas.
shouldUpdate Boolean Should the class be updated if it already exists?

Dependencies (2)

Dev Dependencies (13)

Package Sidebar

Install

npm i parse-utils

Weekly Downloads

2

Version

2.12.1

License

none

Last publish

Collaborators

  • mmazzarolo