save-usergrid

1.4.1 • Public • Published

save-usergrid

Build Status

Usergrid persistance engine for save

Installation

npm install save-usergrid

Usage

var save = require('save') // npm install save
  , usergrid = require('save-usergrid')
  , collection = 'contacts'
  , auth =
    { host: 'https://localhost'
    , org: 'org'
    , app: 'app'
    , grantType: 'client_credentials'
    , clientId: 'client'
    , clientSecret: 'such secret, much wow'
    }
 
// Create a save instance and pass in a Usergrid engine.
var contactStore = save('Contact', { engine: usergrid(collection, auth) })
 
// Then we can create a new entity.
contactStore.create({ name: 'James', email: 'jamesmortemore@gmail.com'}, function (error, contact) {
 
  // The created 'contact' is returned and has been given a uuid
  console.log(contact)
})
 
// Lets find that entity with a query
contactStore.findOne('SELECT * WHERE name = James', function (error, contact) {
  // Will be the entity created above
  console.log(contact)
})
 
// Lets update the entity
contactStore.read('1234-1234-1234-1235', function (error, contact) {
  contact.name = 'Jamez'
 
  contactStore.update(contact, function (error, updatedContact) {
    console.log(updatedContact)
  })
})
 
// Lets delete the entity
contactStore.delete('1234-1234-1234-1235', function (error, contact) {
  // Entire entity that was deleted
  console.log(contact)
})

Package Sidebar

Install

npm i save-usergrid

Weekly Downloads

2

Version

1.4.1

License

ISC

Last publish

Collaborators

  • confuser