SenecaEntityWrapper

SenecaEntityWrapper

This just wraps over the object which is created when you call make.

The fields$, is$, clone$, data$, canon$, native$ methods all work the exact same way as the original seneca entity.

Constructor

new SenecaEntityWrapper(entity)

Parameters:
Name Type Description
entity Object

The entity returned when you call the real seneca.make$ method.

Source:

Methods

list$(query) → {Promise}

Returns a list of entities.

Parameters:
Name Type Description
query Object

The query to pass down to the internal seneca instance. The query dsl will depdend on what kind of module you're using with the entity module.

Source:
Returns:
Type
Promise
Example
const allPersons = seneca.make('person').list$({ all$: true });

load$(query) → {Promise}

Loads an entity.

Parameters:
Name Type Description
query Object

Query to pass down to the internal seneca instance.

Source:
Returns:
Type
Promise
Example
const funnyJoe = seneca
  .make('person')
  .load$({ funny: true, name: 'Joe' });

remove$(query) → {Promise}

Removes the given entity

Parameters:
Name Type Description
query Object

The query to pass to the internal seneca instance. If not specified will use the fields stored on the entity itself.

Source:
Returns:
Type
Promise
Example
// Creates then removes the entity immediately.
seneca
  .make('person')
  .save$({ name: 'foobar' })
  .then((ent) => ent.remove$());

save$(obj) → {Promise}

Saves the stored entity

Parameters:
Name Type Description
obj Object

Optional object to use for saving. If not specified it will use the members on the entity object itself as the data to save.

Source:
Returns:
Type
Promise
Example
const ent = seneca.make('person');
ent.id = 1;
ent.name = 'foobar';
ent.save$(); // => Promise