Base
CRUD using the Base SDK
Create, Read, Update, and Delete your JSON data.
Creating a Base
First, create a Base instance to start working with your data:
Copy
const myBase = db.Base("my-awesome-base")
Copy
const myBase = db.Base("my-awesome-base")
Copy
my_base = db.Base("my-awesome-base")
Adding Data
Single Item (PUT)
Copy
const item = {
name: "Contiguity",
is_awesome: true,
coolness_level: 9000
}
await myBase.put(item, "unique-key-1")
Copy
const item = {
name: "Contiguity",
is_awesome: true,
coolness_level: 9000
}
await myBase.put(item, "unique-key-1")
Copy
item = {
"name": "Contiguity",
"is_awesome": True,
"coolness_level": 9000
}
my_base.put(item, "unique-key-1")
Multiple Items (PUT Many)
Copy
const items = [
{ name: "Item 1", value: 100 },
{ name: "Item 2", value: 200 }
]
await myBase.putMany(items)
Copy
const items = [
{ name: "Item 1", value: 100 },
{ name: "Item 2", value: 200 }
]
await myBase.putMany(items)
Copy
items = [
{"name": "Item 1", "value": 100},
{"name": "Item 2", "value": 200}
]
my_base.put(items)
Reading Data (GET)
Copy
const item = await myBase.get("unique-key-1")
console.log(item.name) // Outputs: Contiguity
Copy
const item = await myBase.get("unique-key-1")
console.log(item.name) // Outputs: Contiguity
Copy
item = my_base.get("unique-key-1")
print(item["name"]) # Outputs: Contiguity
Updating Data (PATCH)
Copy
await myBase.update({
coolness_level: 9001
}, "unique-key-1")
Copy
await myBase.update({
coolness_level: 9001
}, "unique-key-1")
Copy
my_base.update({
"coolness_level": 9001
}, "unique-key-1")
Deleting Data (DELETE)
Copy
await myBase.delete("unique-key-1")
Copy
await myBase.delete("unique-key-1")
Copy
my_base.delete("unique-key-1")
Was this page helpful?
Assistant
Responses are generated using AI and may contain mistakes.