Class: DBObjectCreateTemplate

amiwo/test/db~ DBObjectCreateTemplate


new DBObjectCreateTemplate(name:, data: [, uri] [, options])

Parameters:
Name Type Argument Description
name: String

valid DBObject name

data: Object

data set

uri Object <optional>

{route, method} object if not POST @ '/api/'

options Object <optional>
Properties
Name Type Argument Default Description
returnedProp: String

name of the property which contains the object / objectId

id: boolean

true => returns an ID only; false => return a full object

check: boolean

set to true to check if data from created object match data

compareFn: function

function that takes (key, createdValue, inputValue, isCreatedValueDBObject) and must return true if value1 is equal to value2. Used, if check is set to true, to check if the created object matches the input data (amiwo's smartEqual by default)

exists String <optional>
err

define behavior if such a DBObject already exists => "reuse", "err"

Source:

Extends

Methods


$compare()

Compare 'createdValue' with 'inputValue' handling special cases

Source:
Returns:
Type
boolean

$createObject()

Create the object dealing with duplicate as per _option.exists

Source:
Returns:

wrapping the created object

Type
Promise

execute()

Create a new DBObject from class 'this._name' by calling the associated route

Overrides:
Source:
Returns:

promise wrapping the created DBObject

Type
Promise