Extends
Members
(static) schema
Defines the schema for this model.
- Source:
(static) services
Defines the services required by this model.
- Source:
(private) __embedded :boolean
True if the model is embedded within a parent.
- boolean
- Inherited From:
- Source:
(private) __embedded_parent :module:flitter-orm/src/model/Model~Model|boolean
If the model is embedded within a parent, this is the reference to that parent. Otherwise, false.
- module:flitter-orm/src/model/Model~Model | boolean
- Inherited From:
- Source:
(private) __relation_cache :module:flitter-orm/src/model/ResultCache~ResultCache
Cache for results of relationship lookups for the instance.
- Inherited From:
- Source:
(private) __schema_instance :module:flitter-orm/src/schema/Schema~Schema|boolean
The holding variable for the instantiated schema.
- Inherited From:
- Source:
(private) _di_allow_defer :boolean
If true, the injector will defer the class if the class requests any services that the container is missing. These services are filled in later and added to the prototype and any instances. True by default.
- boolean
- Inherited From:
- Source:
(private) _di_deferred_instances :Array.<module:flitter-di/src/Injectable~Injectable>
Collection of instances of this class that need to have the deferred service instances injected into them when the deferred services are finally provided.
- Source:
(private) _di_deferred_services :Array.<string>
List of services that were deferred and not provided at the time of injection.
- Array.<string>
- Source:
collection :string|boolean
Optionally, the name of the collection where this model should have its records stored. If none is provided, the collection will be the name of the class.
- string | boolean
- Inherited From:
- Source:
id
If defined, will return the string-form ID of this model.
- Inherited From:
- Source:
scopes :Array.<module:flitter-orm/src/model/Scope~Scope>
Array of instantiated references to Scopes that should be applied to this model.
- Inherited From:
- Source:
Methods
(static) getAccessToken(bearerToken, callback)
Given the access token, retrieve the information about that token in the format supported by node-oauth2-server.
Name | Type | Description |
---|---|---|
bearerToken |
string | the bearer token |
callback |
function | passed boolean for error, and null or the result of this.serialize() on success |
- Source:
(static) getAuthCode(bearerCode, callback)
Given a bearer token, generate an instance of {module:flitter-auth/model/Oauth2AuthorizationTicket~Oauth2AuthorizationTicket}
Name | Type | Description |
---|---|---|
bearerCode |
string | the bearer token |
callback |
function | passed boolean for error, and null or object of information about the token |
- Source:
(static) getClient(clientID, clientSecret, callback)
Get an instance of the {module:flitter-auth/model/Oauth2Client~Oauth2Client} model with the corresponding client id and secret.
Name | Type | Description |
---|---|---|
clientID |
string | the client ID |
clientSecret |
string | the client secret |
callback |
function | passed boolean for error as the first param and the client or null for the second |
- Source:
(static) getUser(username, password, callback)
Attempts to authenticate a user by username and password. If that succeeds, fetches the {module:flitter-auth/model/User~User} instance.
Name | Type | Description |
---|---|---|
username |
string | the username |
password |
string | the attempted password |
callback |
function | passed boolean for error, and null or instance of the User on success |
- Source:
(static) grantTypeAllowed(clientID, grantType, callback)
Determines if the client with the specified ID is allowed to use the specified grant type.
Name | Type | Description |
---|---|---|
clientID |
string | the client ID |
grantType |
string | the grant type |
callback |
function | passed boolean for error and boolean for whether the client can use the grant type |
- Source:
(static) saveAccessToken(accessToken, clientID, expires, user, callback)
Save a new instance of this access token with the given parameters.
Name | Type | Description |
---|---|---|
accessToken |
string | the access token |
clientID |
string | the associated client ID |
expires |
Date | the datetime when the token expires |
user |
module:flitter-auth/model/User~User | the associated User instance |
callback |
function | passed null on success, or an error |
- Source:
(private) __collection() → {Collection}
Get the MongoDB collection instance for this model.
- Inherited From:
- Source:
- Type
- Collection
(async, private) __scope_limit_save(db_object) → {Promise.<object>}
Allow all of the model's registerd scopes to modify the schema-cast database object before it is persisted.
Name | Type | Description |
---|---|---|
db_object |
object |
- Inherited From:
- Source:
- modified db_object
- Type
- Promise.<object>
(private) __set_values(data, current_objectopt, current_schemaopt)
Shallow copy the values from the specified object to this model.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
data |
object | |||
current_object |
object |
<optional> |
false | for recursion. The current object scope. |
current_schema |
object |
<optional> |
false | for recursion. The current schema level. |
- Inherited From:
- Source:
belongs_to_many(OtherModel, local_key, foreign_keyopt) → {Promise.<Array.<module:flitter-orm/src/model/Model~Model>>|Array.<module:flitter-orm/src/model/Model~Model>}
Associates many records of another model with this model based on a local/foreign key relationship.
Normally, this would be automatically returned by a named method on the sub-class that implements the relationship.
This returns a cached result. So, it will only return a promise on the first call. Subsequent calls will return the results from the cache and are, therefore, synchronous.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
OtherModel |
module:flitter-orm/src/model/Model~Model | static class of the other model |
||
local_key |
string | local key of the field to match |
||
foreign_key |
string |
<optional> |
'' | foreign key of the field to match (if none provided, assume the same as local_key) |
- Inherited From:
- Source:
- the matching model instances
- Type
- Promise.<Array.<module:flitter-orm/src/model/Model~Model>> | Array.<module:flitter-orm/src/model/Model~Model>
belongs_to_one(OtherModel, local_key, foreign_keyopt) → {Promise.<(module:flitter-orm/src/model/Model~Model|undefined)>|module:flitter-orm/src/model/Model~Model}
Associates a single record of another model with this model based on a local/foreign key relationship.
Normally, this would be automatically returned by a named method on the sub-class that implements the relationship.
This returns a cached result. So, it will only return a promise on the first call. Subsequent calls will return the results from the cache and are, therefore, synchronous.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
OtherModel |
module:flitter-orm/src/model/Model~Model | static class of the other model |
||
local_key |
string | local key of the field to match |
||
foreign_key |
string |
<optional> |
'' | foreign key of the field to match (if none provided, assume the same as local_key) |
- Inherited From:
- Source:
- the matching model instance
- Type
- Promise.<(module:flitter-orm/src/model/Model~Model|undefined)> | module:flitter-orm/src/model/Model~Model
(async) delete() → {Promise.<module:flitter-orm/src/model/Model~Model>}
Delete the current instance of this model from the database. This will remove the model's ID from this instance. Other properties will remain unchanged.
- Inherited From:
- Source:
- Type
- Promise.<module:flitter-orm/src/model/Model~Model>
has_many(OtherModel, local_key, foreign_keyopt) → {Promise.<Array.<module:flitter-orm/src/model/Model~Model>>|Array.<module:flitter-orm/src/model/Model~Model>}
Associates many records of another model with this model based on a local/foreign key relationship.
Normally, this would be automatically returned by a named method on the sub-class that implements the relationship.
This returns a cached result. So, it will only return a promise on the first call. Subsequent calls will return the results from the cache and are, therefore, synchronous.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
OtherModel |
module:flitter-orm/src/model/Model~Model | static class of the other model |
||
local_key |
string | local key of the field to match |
||
foreign_key |
string |
<optional> |
'' | foreign key of the field to match (if none provided, assume the same as local_key) |
- Inherited From:
- Source:
- the matching model instances
- Type
- Promise.<Array.<module:flitter-orm/src/model/Model~Model>> | Array.<module:flitter-orm/src/model/Model~Model>
has_one(OtherModel, local_key, foreign_keyopt) → {Promise.<module:flitter-orm/src/model/Model~Model>|module:flitter-orm/src/model/Model~Model}
Associates a single record of another model with this model based on a local/foreign key relationship.
Normally, this would be automatically returned by a named method on the sub-class that implements the relationship.
This returns a cached result. So, it will only return a promise on the first call. Subsequent calls will return the results from the cache and are, therefore, synchronous.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
OtherModel |
module:flitter-orm/src/model/Model~Model | static class of the other model |
||
local_key |
string | local key of the field to match |
||
foreign_key |
string |
<optional> |
'' | foreign key of the field to match (if none provided, assume the same as local_key) |
- Inherited From:
- Source:
- the matching model instance
(async) save() → {Promise.<module:flitter-orm/src/model/Model~Model>}
Persist this model instance to the database. This will store only values defined in the schema for this model, and, in so doing, will cast those values and fill in the specified defaults. These changes will be added to this instance after the save.
- Inherited From:
- Source:
- the current instance with updated properties
- Type
- Promise.<module:flitter-orm/src/model/Model~Model>
serialize() → {object}
Serializes this instance to the format understood by node-oauth2-server.
- Source:
- Type
- object
(async) set(field, value) → {Promise.<module:flitter-orm/src/model/Model~Model>}
A convenience method. Set the specified field on this model equal to the specified property and immediately save the record.
Name | Type | Description |
---|---|---|
field |
string | |
value |
* |
- Inherited From:
- Source:
- Type
- Promise.<module:flitter-orm/src/model/Model~Model>