Created
May 7, 2012 19:59
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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: '[email protected]', pw: 'w00t', occupation: 'jsdeveloper' }); | |
user.create(); | |
.... | |
//this fetches a single user instance who's email (primary key) is '[email protected]' | |
var user = new CustomUser({ email: '[email protected]' }); | |
user.fetch(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment