Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (46 sloc) 2.18 KB
Database Operations
Save objects: proton.db('things').save(<object>)
Remove matching objects: proton.db('things').remove(<query>)
Remove all objects: proton.db('things').clear()
Update matching objects: proton.db('things').update(<update>,<query>)
Query matching objects: <array> proton.db('things').find(<query>)
<array> proton.db('things').find(<query>,<query>,<query>...)
Get all objects: <array> proton.db('things').all()
Get distinct objects: <array> proton.db('things').distinct()
Match objects: <bool> proton.match(<object>, <query>)
A sample <object>: {name:'Alex Trabeck', occupation:'Game Show Host', favorites:{bird:'robin', color:'blue'}}
A sample <query>:
(simple) {occupation: 'Game Show Host'}
(stock function) {salary: proton.greaterThan(100000)}
(custom function) {occupation: function(value) { return value.charAt(3) == 'e' } }
(complex) {occupation: 'Game Show Host', salary: proton.greaterThan(100000)}
(regex) {occupation: /Game/)
(deep) (name: 'Alex Trabeck', favorites: {color: 'blue'} }
A sample <update>:
(add) {salary: 250000}
(remove) {occupation: undefined}
(change) {occupation: 'Spokesman'}
A sample <sort>: {occupation: proton.ascending, salary: proton.descending}
Array Operations
(empty) new Array()
(copy) new Array('foo','bar','baz')
Filter array: <array> things.sift(<query>)
First set of items: <array>
Last set of items: <array> things.bottom(3)
Paged items: <array>,20)
First object <object> things.first()
Last object: <object> things.last()
Distinct items: <array> Array.distinct()
Sort array: <array> Array.order(<sort>)
Complex queries: <array> proton.db('things').all().distinct().sift(<query>).order(<sort>).top()
Meta Operations
List of sets: <array> proton.sets()
Dump all sets: <list> proton.dump()
Clear all sets: proton.wipe()