Class: DatabaseObject

DatabaseObject()

new DatabaseObject()

Represents a database object
Do not call constructor directly
Source:
See:

Members

(readonly) id :object

The database object id
Type:
  • object
Source:

(readonly) timestamp :Date

The database object timestamp. When it was created or updated
Type:
  • Date
Source:

Methods

appendTo(parent, collection) → {DatabaseObject}

Add this database object to a parent database object collection field
Parameters:
Name Type Description
parent DatabaseObject parent database object
collection collection the field in the parent object representing a collection (Array)
Source:
Returns:
this database object
Type
DatabaseObject

clear() → {DatabaseObject}

Clear all data in this database object to be reused
Source:
Returns:
this database object
Type
DatabaseObject

delete()

Delete this object from the database
Source:

get(key) → {Object}

Get a field value
Parameters:
Name Type Description
key string the field name
Source:
Returns:
the property value
Type
Object

has() → {boolean}

Test if a specific is in this database object
Source:
Returns:
true or false
Type
boolean

increment(field, value) → {integer}

Increment the value of an integer property in this database object.
To decremt, use a negative value
Parameters:
Name Type Description
field string field name
value integer the increment
Source:
Returns:
the new value
Type
integer

keys() → {Array}

List all object fields names
Source:
Returns:
fields names
Type
Array

load(valuesopt) → {DatabaseObject}

Load data into this database object
Parameters:
Name Type Attributes Description
values JsonObject <optional>
key/value data to load
Source:
Returns:
this database object
Type
DatabaseObject

ref(key, entity, id) → {DatabaseObject}

Set a 1-1 field value
Parameters:
Name Type Description
key string the field name
entity string the reference entity name
id object the reference id
Source:
Returns:
the database object
Type
DatabaseObject

remove(key) → {DatabaseObject}

Remove a field from this object
Parameters:
Name Type Description
key string the field name
Source:
Returns:
this database object
Type
DatabaseObject

removeFrom(parent, collection) → {DatabaseObject}

Remove this database object from a parent database object collection field
Parameters:
Name Type Description
parent DatabaseObject parent database object
collection collection the field in the parent object representing a collection (Array)
Source:
Returns:
this database object
Type
DatabaseObject

save() → {DatabaseObject}

Save this database object to reflect changes made to it
Source:
Returns:
this database object
Type
DatabaseObject

set(key, value) → {DatabaseObject}

Set a field value
Parameters:
Name Type Description
key string the field name
value object the field value
Source:
Returns:
the database object
Type
DatabaseObject

toJson(allStopLevel) → {JsonObject}

Get a this database object data as Json
Parameters:
Name Type Description
allStopLevel function a function to filter which key/value pairs to serialize (optional)
Source:
Returns:
the database object as a json object
Type
JsonObject

useDefaultFields() → {DatabaseObject}

Use default assigned values auto uuid and timestamp. If set to false, id and timestamp will not be added to the database object
Source:
Returns:
this database object
Type
DatabaseObject