Class: Record

Record


new Record(props, opts)

js-data's Record class.

import {Record} from 'js-data'
Parameters:
Name Type Argument Description
props Object <optional>

The initial properties of the new Record instance.

opts Object <optional>

Configuration options.

Properties
Name Type Argument Default Description
noValidate boolean <optional>
false

Whether to skip validation on the initial properties.

Source:

Extends

Members


_listeners :Object

Event listeners attached to this Component. Do not modify. Use Component#on and Component#off instead.

Type:
  • Object
Inherited From:
Source:

Methods


afterLoadRelations(relations, opts)

TODO

Parameters:
Name Type Description
relations Array.<string>

TODO

opts Object

TODO

Source:

beforeLoadRelations(relations, opts)

TODO

Parameters:
Name Type Description
relations Array.<string>

TODO

opts Object

TODO

Source:

changes(opts)

Return changes to this record since it was instantiated or Record#commit was called.

Parameters:
Name Type Argument Description
opts <optional>

Configuration options.

Properties
Name Type Argument Description
equalsFn function <optional>

Equality function. Default uses ===.

ignore Array <optional>

Array of strings or RegExp of fields to ignore.

Source:

commit()

TODO

Source:

dbg()

TODO

Inherited From:
Source:

destroy(opts)

Call Mapper#destroy using this record's primary key.

Parameters:
Name Type Argument Description
opts Object <optional>

Configuration options passed to Mapper#destroy.

Source:
Returns:

The result of calling Mapper#destroy.

Type
Promise

emit(event, args)

Trigger an event on this Component.

Parameters:
Name Type Argument Description
event string

Name of event to emit.

args * <optional>
<repeatable>

Arguments to pass to any listeners.

Inherited From:
Source:

get(key)

Return the value at the given path for this instance.

Parameters:
Name Type Description
key string

Path of value to retrieve.

Source:
Returns:

Value at path.

Type
*

hasChanges(opts)

Return whether this record has changed since it was instantiated or Record#commit was called.

Parameters:
Name Type Argument Description
opts <optional>

Configuration options.

Properties
Name Type Argument Description
equalsFn function <optional>

Equality function. Default uses ===.

ignore Array <optional>

Array of strings or RegExp of fields to ignore.

Source:

hashCode()

TODO

Source:

loadRelations(relations, opts)

TODO

Parameters:
Name Type Argument Description
relations Array.<string> <optional>

TODO

opts Object <optional>

TODO

Source:

log()

TODO

Inherited From:
Source:

off(event, listener)

Remove an event listener from this Component. If no listener is provided, then all listeners for the specified event will be removed. If no event is specified then all listeners for all events will be removed.

Parameters:
Name Type Argument Description
event string <optional>

Name of event to unsubsribe to.

listener function <optional>

Listener to remove.

Inherited From:
Source:

on(event, listener, ctx)

Register a new event listener on this Component.

Parameters:
Name Type Argument Description
event string

Name of event to subsribe to.

listener function

Listener function to handle the event.

ctx * <optional>

Optional content in which to invoke the listener.

Inherited From:
Source:

previous(key)

TODO

Parameters:
Name Type Argument Description
key string <optional>

TODO

Source:

revert(opts)

TODO

Parameters:
Name Type Argument Description
opts Object <optional>

Configuration options.

Source:

save(opts, opts)

Delegates to Mapper#create or Mapper#update.

Parameters:
Name Type Argument Description
opts Object <optional>

Configuration options. See Mapper#create.

opts <optional>

Configuration options.

Properties
Name Type Argument Description
changesOnly boolean <optional>

Equality function. Default uses ===.

equalsFn function <optional>

Passed to Record#changes when changesOnly is true.

ignore Array <optional>

Passed to Record#changes when changesOnly is true.

Source:
Returns:

The result of calling Mapper#create or Mapper#update.

Type
Promise

set(key, value, opts)

Set the value for a given key, or the values for the given keys if "key" is an object.

Parameters:
Name Type Argument Description
key string | Object

Key to set or hash of key-value pairs to set.

value * <optional>

Value to set for the given key.

opts Object <optional>

Optional configuration.

Properties
Name Type Argument Default Description
silent boolean <optional>
false

Whether to trigger change events.

Source:

toJSON(opts)

Return a plain object representation of this record. If the class from which this record was created has a mapper, then Mapper#toJSON will be called instead.

Parameters:
Name Type Argument Description
opts Object <optional>

Configuration options.

Properties
Name Type Argument Description
with Array.<string> <optional>

Array of relation names or relation fields to include in the representation. Only available as an option if the class from which this record was created has a mapper.

Source:
Returns:

Plain object representation of this record.

Type
Object

unset(key, opts)

Unset the value for a given key.

Parameters:
Name Type Argument Description
key string

Key to unset.

opts Object <optional>

Optional configuration.

Properties
Name Type Argument Default Description
silent boolean <optional>
false

Whether to trigger change events.

Source: