signUp

DatabaseUser.signUp(dbApiKey, userJSON)

Sings up a user. This method will create a new record in the Users collection. The username value has to be unique.

Parameters

The method has the following parameters:

ArgumentDescriptionRequired
dbApiKeyString with database API key.Yes.
userJSONUser JSON object. This object holds username, password and any additional data.Yes.

Response

The method has the following response. If the Users collection has additional custom columns, those columns will be returned as well.

{
   "username":<username>,
   "_createdAt":<datetime>,
   "_updatedAt":<datetime>,
   "_id":<user_id>,
   "sessionToken":<session_token>
}
Examples

Basic Signup

This example shows how to sign up (register) a user with just the username and password. This the minimum information you have to provide to create a new user.

var dbApiKey = "57928860e4b00ef864f3dc24"
var username = "amy";
var password = "123";

var user = DatabaseUser.signUp(dbApiKey, {
  "username": "monica",
  "password": "123"
});
Apperyio.response.success(user, "application/json");
{
	"_createdAt": {
		"$date": "2016-08-10T23:02:51.711Z"
	},
	"sessionToken": "01a1a4e8-1b4d-4f56-8439-7386a2806235",
	"_id": "57abb29be4b05ed524a72a4b",
	"username": "alex",
	"_updatedAt": {
		"$date": "2016-08-10T23:02:51.713Z"
	}
}
Signup with Additional Information

This examples includes additional information (Notes and isActive columns) that are present in the Users collection:

var dbApiKey = "57928860e4b00ef864f3dc24"
var username = "amy";
var password = "123";

var user = DatabaseUser.signUp(dbApiKey, {
  "username": "alex",
  "password": "123",
  "Notes": "A user just craeted",
  "isActive": true
});
Apperyio.response.success(user, "application/json");
{
	"_updatedAt": {
		"$date": "2016-08-10T23:04:57.565Z"
	},
	"_createdAt": {
		"$date": "2016-08-10T23:04:57.563Z"
	},
	"_id": "57abb319e4b08e80b78ec571",
	"username": "alex",
	"Notes": "A user just craeted",
	"isActive": true,
	"sessionToken": "57ff6c4c-6601-4460-b01d-7db3be0c65a9"
}