Remove app.modelBuilder()
This commit is contained in:
parent
044d2c4bcc
commit
2a30efe23f
12
README.md
12
README.md
|
@ -803,6 +803,8 @@ The Asteroid library is unopinioned in the way you define your app's data and lo
|
||||||
- Email - _TODO_ schedule and send emails to your app users using smtp or 3rd party services.
|
- Email - _TODO_ schedule and send emails to your app users using smtp or 3rd party services.
|
||||||
- Job - _TODO_ schedule arbitrary code to run at a given time.
|
- Job - _TODO_ schedule arbitrary code to run at a given time.
|
||||||
|
|
||||||
|
Defining a model with `asteroid.createModel()` is really just extending the base `asteroid.Model` type using `asteroid.Model.extend()`. The bundled models extend from the base `asteroid.Model` allowing you to extend them arbitrarily.
|
||||||
|
|
||||||
### User Model
|
### User Model
|
||||||
|
|
||||||
Register and authenticate users of your app locally or against 3rd party services.
|
Register and authenticate users of your app locally or against 3rd party services.
|
||||||
|
@ -812,7 +814,7 @@ Register and authenticate users of your app locally or against 3rd party service
|
||||||
Extend a vanilla Asteroid model using the built in User model.
|
Extend a vanilla Asteroid model using the built in User model.
|
||||||
|
|
||||||
// define a User model
|
// define a User model
|
||||||
var User = asteroid.createModel(
|
var User = asteroid.User.extend(
|
||||||
'user',
|
'user',
|
||||||
{
|
{
|
||||||
email: {
|
email: {
|
||||||
|
@ -825,9 +827,6 @@ Extend a vanilla Asteroid model using the built in User model.
|
||||||
min: 4,
|
min: 4,
|
||||||
max: 26
|
max: 26
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
extend: 'User',
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -923,7 +922,7 @@ You must provide a username and password over rest. To ensure these values are e
|
||||||
To require email verification before a user is allowed to login, supply a verification property with a `verify` settings object.
|
To require email verification before a user is allowed to login, supply a verification property with a `verify` settings object.
|
||||||
|
|
||||||
// define a User model
|
// define a User model
|
||||||
var User = asteroid.createModel(
|
var User = asteroid.User.extend(
|
||||||
'user',
|
'user',
|
||||||
{
|
{
|
||||||
email: {
|
email: {
|
||||||
|
@ -949,7 +948,6 @@ To require email verification before a user is allowed to login, supply a verifi
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
extend: 'User',
|
|
||||||
// the model field
|
// the model field
|
||||||
// that contains the user's email
|
// that contains the user's email
|
||||||
// for verification and password reset
|
// for verification and password reset
|
||||||
|
@ -959,7 +957,7 @@ To require email verification before a user is allowed to login, supply a verifi
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
When a user is created (on the server or remotely) an email is sent to the field that corresponds to `verify.email` or `options.email`. The email contains a link the user must navigate to in order to verify their email address. Once they verify, users are allowed to login normally. Otherwise login attempts will respond with a 'must verify' error.
|
When a user is created (on the server or remotely) and the verification property exists, an email is sent to the field that corresponds to `verify.email` or `options.email`. The email contains a link the user must navigate to in order to verify their email address. Once they verify, users are allowed to login normally. Otherwise login attempts will respond with a 'must verify' error.
|
||||||
|
|
||||||
#### Send Reset Password Email
|
#### Send Reset Password Email
|
||||||
|
|
||||||
|
|
|
@ -39,14 +39,6 @@ app.disuse = function (route) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get ModelBuilder.
|
|
||||||
*/
|
|
||||||
|
|
||||||
app.modelBuilder = function () {
|
|
||||||
return this._modelBuilder || (this._modelBuilder = new ModelBuilder())
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* App models.
|
* App models.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -464,6 +464,40 @@ describe('Model', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// describe('Model.extend()', function(){
|
||||||
|
// it('Create a new model by extending an existing model.', function(done) {
|
||||||
|
// var User = asteroid.Model.extend('user', {
|
||||||
|
// email: String
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// User.foo = function () {
|
||||||
|
// return 'bar';
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// User.prototype.bar = function () {
|
||||||
|
// return 'foo';
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// var MyUser = User.extend('my-user', {
|
||||||
|
// foo: String,
|
||||||
|
// bar: String
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// assert(MyUser.prototype.bar === User.prototype.bar);
|
||||||
|
// assert(MyUser.foo === User.foo);
|
||||||
|
//
|
||||||
|
// var user = new MyUser({
|
||||||
|
// email: 'foo@bar.com',
|
||||||
|
// foo: 'foo',
|
||||||
|
// bar: 'bar'
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
// assert.equal(user.email, 'foo@bar.com');
|
||||||
|
// assert.equal(user.foo, 'foo');
|
||||||
|
// assert.equal(user.bar, 'bar');
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
// describe('Model.hasAndBelongsToMany()', function() {
|
// describe('Model.hasAndBelongsToMany()', function() {
|
||||||
// it("TODO: implement / document", function(done) {
|
// it("TODO: implement / document", function(done) {
|
||||||
// /* example -
|
// /* example -
|
||||||
|
|
Loading…
Reference in New Issue