2.0 KiB
2.0 KiB
Record.js API
constructor
Parameters
Examples
// create a new record (in-memory)
let pets = new Record();
// create a new record (localStorage)
let pets = new Record({"store": "pets"});
add
Add record to collection creating an sudo unique id if one not provided
Parameters
entry
Object object(s) you want to store
Examples
// add pet to collection
let dog = pets.add({"name": "Yonkers", "age": 5});
// > [{"id": "14rj345k9", "name": "Yonkers", "age": 5}]
Returns object entry added
find
Finds records in collection by id or object filter.
Parameters
Examples
// find all
let all = collection.find();
// find by id
let record = collection.find(1);
// filter by object
let dogs = collection.find({"type": "dog"});
Returns array matching records
remove
Remove record(s) from collection. Leverages same functionality as find
Parameters
entry
any (optional)
Examples
// remove all records by type
let removed = collection.remove({"type": "cat"});
// > []
Returns array records removed
count
Returns number count of records in collection