Functions
List of all the functions available in a depot
Values
The values method return the collection as an array
books.values() // Returns [{}, {}, {}, ...]Add
Create the record into the collection with a fresh uuid.
const book = {
title: "The Call of Cthulhu",
author: "H. P. Lovercraft",
year: 1928
}
// Add a single item
books.add(book)
// Add multiple items
books.add(book, book2, ...)Save
Update the records based on their uuid
const book = { ...books.last(), checked: true }
// Save a single item
books.save(book)
// Save multiple items
books.save(book, book2, ...)Delete
Remove records based on their uuid.
It accepts as well the plain uuid of the records instead of the objects.
// Remove a single item
books.remove(book)
books.remove("b96ab5e6-f1e8-4653-ab08-4dd82ea65778")
// Remove multiple items
books.remove(book, book2, ...)
books.remove("b96ab5e6-f1e8-4653...", "0b99b82f-62cf-4275...", ...)Empty
Remove all the records of a collection.
books.empty()Find
Returns the first object that matches the given filter.
books.find({ title: "Call" })First
Returns the first object.
books.first() // Returns { id: "b96ab5e6...", title: "The Call of Cthulhu" } Last
Returns the latest added object.
books.last()Size
Returns the length of the collection.
books.size()Last updated
Was this helpful?