Constructor
new HasOne(definition, modelInstance) → {HasOne}
HasOne subclass
Parameters:
Name | Type | Description |
---|---|---|
definition |
RelationDefinition | Object | |
modelInstance |
Object |
- Source:
Returns:
- Type
- HasOne
Methods
get(cb) → {Promise|Undefined}
Define a Promise-based method for the hasOne relation itself
- order.customer.get(cb): Load the target model instance asynchronously
Parameters:
Name | Type | Description |
---|---|---|
cb |
function | Callback of the form function (err, inst) |
- Source:
Returns:
Returns promise if cb is omitted
- Type
- Promise | Undefined
related(refresh, params) → {Object}
Define the method for the hasOne relation itself
It will support one of the following styles:
- order.customer(refresh, callback): Load the target model instance asynchronously
- order.customer(customer): Synchronous setter of the target model instance
- order.customer(): Synchronous getter of the target model instance
Parameters:
Name | Type | Description |
---|---|---|
refresh |
Boolean | Reload from the data source |
params |
Object | function | Query parameters |
- Source:
Returns:
- Type
- Object