Collections API
When querying multiple objects via users
, flows
, and table
.
get(object_id) | Return an object associated with the object_id. |
filter(**conditions, order_by=[]) | Return a list of objects matching the filters provided:c1 , c2 , ... , cN and orderer by the fields provided in order_by |
update(object_id, data) | Update the object's data, but not overwriting other data. |
put(object_id, data) | Update and overwrite the object completely. |
delete(object_id) | Delete the objects. |
all() | Return a list of all objects for the collection. |
add(data) | Add a new objects to the collection. |
self.db.users.get("Uxxxxxxxxx")
{
'id': 'Uxxxxxxxxx',
'name': 'Nikola',
'dob': 'July 10, 1856'
}
self.db.table('products').filter(
price__lt=100,
category='toys'
order_by=['-price', 'name']
)
[
{
"id": "O111111111",
"category": "toys",
"price": 45.12
"name": "Bop-it"
},
{
"id": "O222222222",
"category": "toys",
"price": 15.99
"name": "Bubble mower"
}
]
import time
order = {
'item': 'Fish burrito',
'price': 8.99,
'created_at': time.time(),
'user_id': self.db.user.id
}
id = self.db.table('orders').add(order)
Updated over 5 years ago