Skip to content

matter-in-motion/mm-record

Repository files navigation

Matter In Motion. Record resource extension

NPM Version NPM Downloads

This extension adds a record resource. Record resource doesn't provide any API. Its main purpose is to record other resources relationship metadata.

Usage

Extensions installation instructions

Record

Record is the object with fields:

  • type — string or number, type of the record.
  • sid — string or number, subject id
  • oid — string or number, optional, object id
  • ts — record timestamp
  • data — any, optional data

API

No API

Controller Methods

add(opts)

Adds a record. Available options:

  • type — string or number, type of the record.
  • sid — string or number, subject id
  • oid — string or number, optional, object id
  • data — any, data to add to the record
  • update — boolean, if true and a record already exists it will update the timestamp of the record

get(id)

Returns a record with id

getAll(opts)

Returns all the records for the options. New records first. Available options:

  • type — selects records by type
  • sid — selects records with subject id
  • oid — also filters records with object id
  • limit — limits result number

has(opts)

Checks if the record of type and with subject sid and/or object oid is available. Return true or false.

  • type — record type
  • sid — record subject id
  • oid — record object id

delete(opts)

Deletes a record

  • type — record type
  • sid — record subject id
  • oid — record object id

deleteAll(id)

Deletes all the records where sid or oid is equal to id (slow method)

search(opts)

Records search (slow method)

  • type — with type
  • sid — with sid
  • oid — with oid
  • sample — number, return a random number of records
  • limit — limits results number
  • count — counts the number of records

Last three options are exclusive.

License: MIT.