Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

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.

Base().delete()

Delete an instance of a Base.

user = await User.get("some key")
await user.delete()

Base().insert()

Insert an instance of a Base.

user = await User(name="Bob").insert()

Base().update()

Update an instance of a Base.

user = await User.get("some key")
new_user = await user.update(
    User.name.set("John")
)

Base.get()

Gets a Base instance from a key.

user = await User.get("some key")

Base.where()

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)

Base.insert_many()

Inserts up to 25 Bases at once.

await User.insert_many([
    User(name="John"),
    User(name="Bob"),
])

Base.delete_item()

Deletes an item by its key.

await User.delete_item("some key")

Base.insert_item()

Inserts an item in to the Base.

await User.insert_item(User(name="Bob"))

Base.update_item()

Updates an item by its key.

await User.update_item("some key", User.name.set("John"))