1.0.2 • Published 5 years ago

goonca-rn-stitch-mongodb-sdk v1.0.2

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

goonca-rn-stitch-mongodb-sdk

This is a react native friendly interface for Stitch MongoDB SDK

Getting started

$ npm install goonca-rn-stitch-mongodb-sdk

import goonca-rn-stitch-mongodb-sdk

import MongoDB from 'goonca-rn-stitch-mongodb-sdk'

Methods

set()

set({..config})

Store database and connections properties

Arguments:

config Object containing (see below for a description of these fields):

NameDescription
appNameStitch application name
dbNameDatabase name
dbUserDatabase username
dbPasswordDatabase password
debugDebug enabled (default=true)
Example
MongoDB.set(
  {
    appName : '<APP_NAME>',
    dbName : '<DB_NAME>',
    dbUser : '<DB_USER>',
    dbPassword : '<DB_PASSWORD>',
    debug : <true|false>
  }
)

connect()

connect(onLoad, onError)

Connect to database using the parameter defined on set().

parameters:

NameDescription
onLoadSuccess return function
onErrorFail return function
Example
MongoDB.connect(
  {
    onLoad : <Function>,
    onError : <Function>
  }
)

authenticate()

authenticate(user, onLoad, onError)

Authenticate database user.

parameters:

NameDescription
userObject user to be authenticated {user.email, user.password}
onLoadSuccess return function
onErrorFail return function
Example
MongoDB.authenticate(
  {
    user : {email : '<USER_EMAIL>', password : '<USER_PASSWORD>'}
    onLoad : <Function>,
    onError : <Function>
  }
)

logout()

logout(onLoad, onError)

Logout current connected database user.

parameters:

NameDescription
onLoadSuccess return function
onErrorFail return function
Example
MongoDB.logout(
  {
    onLoad : <Function>,
    onError : <Function>
  }
)

confirm()

confirm(token, tokenId, onLoad, onError)

Confirm new user register.

parameters:

NameDescription
tokenUser token
tokenIdUser tokenId
onLoadSuccess return function
onErrorFail return function
Example
MongoDB.confirm(
  {
    token : '<USER_TOKEN>',
    tokenId : '<USER_TOKEN_ID>',
    onLoad : <Function>,
    onError : <Function>
  }
)

register()

register(user, onLoad, onError)

Register user register.

parameters:

NameDescription
userObject new user {user.email, user.password}
onLoadSuccess return function
onErrorFail return function
Example
MongoDB.register(
  {
    user : {email : '<USER_EMAIL>', password : '<USER_PASSWORD>'}
    tokenId : '<USER_TOKEN_ID>',
    onLoad : <Function>,
    onError : <Function>
  }
)

update()

update(obj, collection, onLoad, onError)

Create or update an object. if the object received has the property id it will be updated otherwise a new Object will be created.

parameters:

NameDescription
objObject to be created/updated
collectionmongoDB collection
onLoadSuccess return function
onErrorFail return function
Example
MongoDB.update(
  {
    obj : {...}
    tokenId : '<MONGO_DB_COLLECTION>',
    onLoad : <Function>,
    onError : <Function>
  }
)

get()

get(collection, param, onLoad, onError)

Return a list of objects from the collection.

parameters:

NameDescription
collectionmongoDB collection
paramObject containing (see below for a description of these fields)
onLoadSuccess return function
onErrorFail return function

(param)

NameDescription
$filterMongo filter
$limitlist max length
$sortASC|DESC
Example
MongoDB.get(
  {
    collection : '<COLLECTION>'
    param : {...},
    onLoad : <Function>,
    onError : <Function>
  }
)