-
Notifications
You must be signed in to change notification settings - Fork 0
3. Adding data
Erzhan edited this page Jun 29, 2019
·
2 revisions
The easiest way to add data into database would be to make an instance of Human
, and then call .save()
. See below for an example:
const myDatastore = ...
const human = new Human('hooman', 24)
console.log(human, human.meta)
await human.save()
console.log(human, human.meta)
//Or:
const human = await new Human('hooman', 24).save()
console.log(human, human.meta)
Notice that human
has additional fields called meta
and store
(which is private), and also has few methods like save()
, delete()
. meta
contains metadata information such as the id
, created
, and updated
, where the last two are milliseconds since epoch.