Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 682 Bytes

updating_and_removing_data.markdown

File metadata and controls

31 lines (22 loc) · 682 Bytes

Updating and Removing Data

Updating

Updating data is easily done through the update method.

david = database.findOne({name: 'david'})
david.name = 'dave'
database.changed(david) // true

database.update(david)

results = database.where({name: 'dave'})
results.length // 1
results = database.where({name: 'david'})
results.length // 0

Update takes an instance of Entry and overwrites the entry in the database with the new one.

Remove

Remove works much the same as Update taking an entry and removing it from the database.

dave = database.where({name: 'dave'})[0]
database.count() // 8
database.remove(dave)
database.count() // 7