Skip to content

Instantly share code, notes, and snippets.

@ericktai
Created May 7, 2012 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericktai/2630012 to your computer and use it in GitHub Desktop.
Save ericktai/2630012 to your computer and use it in GitHub Desktop.
Custom User Schema and Fields in JS SDK 0.2.1 and below
/*
These instructions are for JS SDK Version 0.2.1 and below on how to add
custom user object with custom login/password fields. You have to let the
JS SDK know what your primary key and password field is, so we'll do that here.
*/
//Let StackMob know what your username/pw fields are
StackMob.init({
appName: ...,
clientSubdomain: ...,
...
//Add the following:
loginField: 'email', //what you named your primary key field
passwordField: 'pw', //what you named your password field
});
//Make sure that StackMob knows which schema you're referring to for your User schema.
var CustomUser = StackMob.User.extend({
schemaName: 'account' //what you named your custom user schema
});
//Creating a new user:
var user = new CustomUser({ email: 'graham@awesomedeveloper.com', pw: 'w00t', occupation: 'jsdeveloper' });
user.create();
....
//this fetches a single user instance who's email (primary key) is 'you@awesomedeveloper.com'
var user = new CustomUser({ email: 'you@awesomedeveloper.com' });
user.fetch();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment