Show:

SQL Database dsl

Constructor

ORM
(
  • models
)

Defined in src/orm.js:6

Parameters:

Methods

createRecord
(
  • modelName
  • payload
)
Promise

Defined in src/orm.js:24

Create a new model instance

Parameters:

  • modelName String

    lowercase singular model name

  • payload Object

    new instance data

Returns:

Promise:

<ModelInstance, RestError>

Example:

return orm.createRecord("user", { firstName: "John" });
destroyRecord
(
  • modelName
  • id
)
Promise

Defined in src/orm.js:61

Destroy a record instance

Parameters:

  • modelName String

    lowercase singular model name

  • id Number | String

    id of the record to destroy

Returns:

Promise

Example:

return orm.destroyRecord("user", 1);
findAll
(
  • modelName
  • where
  • options
)
Promise

Defined in src/orm.js:79

Return all instances of a model and optionally pass a query object

Parameters:

Returns:

Promise:

<ModelInstance, RestError>

Example:

return orm.findAll("user");

// you can also query

return orm.findAll("user", { firstName: { $like: "john" }});
findOne
(
  • modelName
  • id
  • options
)
Promise

Defined in src/orm.js:107

Return a single instance by id

Parameters:

Returns:

Promise:

<ModelInstance, RestError>

Example:

return orm.findOne("user", 1);
queryRecord
(
  • modelName
  • where
  • options
)
Promise

Defined in src/orm.js:129

Like findOne but takes a query instead of an id

Parameters:

Returns:

Promise:

<ModelInstance, RestError>

Example:

return orm.queryRecord("user", { firstName: "John" });
updateRecord
(
  • modelName
  • id
  • payload
)
Promise

Defined in src/orm.js:162

Update a record

Parameters:

  • modelName String

    lowercase singular model name

  • id Number | String

    id of the record to destroy

  • payload Object

    new instance data

Returns:

Promise:

<ModelInstance, RestError>

Example:

return orm.updateRecord("user", 1, { firsName: "Joe" });