This repository has been archived by the owner on Oct 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Base Methods
CircuitSacul edited this page Sep 27, 2022
·
1 revision
Each Base has a list of methods that abstract the methods on Client to make usage easier.
Delete an instance of a Base.
user = await User.get("some key")
await user.delete()
Insert an instance of a Base.
user = await User(name="Bob").insert()
Update an instance of a Base.
user = await User.get("some key")
new_user = await user.update(
User.name.set("John")
)
Gets a Base instance from a key.
user = await User.get("some key")
Creates a paginator over the Base, given some query parameters.
page = await User.where(User.name == "John", limit=1)
print(page.items) # prints the one user that was fetched
next_page = await page.next() # returns None, since that was the last page
async for page in User.where(User.score > 50):
for user in page.items:
print(user)
Inserts up to 25 Bases at once.
await User.insert_many([
User(name="John"),
User(name="Bob"),
])
Deletes an item by its key.
await User.delete_item("some key")
Inserts an item in to the Base.
await User.insert_item(User(name="Bob"))
Updates an item by its key.
await User.update_item("some key", User.name.set("John"))
Feel free to contribute to this wiki; Just try to follow the general idea use for other pages. (Also make sure to add any pages you create to the sidebar.)