Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Using AvionDB with Browser
<!--Using AvionDB in Browser-->
<!--IPFS CDN Link-->
<script src=""></script>
<!--AvionDB CDN Link-->
<script src=""></script>
<script type="text/javascript">
const runExample = async () => {
const ipfs = await window.Ipfs.create();
// Creates a db named "DatabaseName"
const aviondb = await AvionDB.init("DatabaseName", ipfs);
// Creates a Collection named "employees"
const collection = await aviondb.initCollection("employees");
// Returns the List of collection names
await aviondb.listCollections()
// prints ['employees']
// Adding an employee document
await collection.insertOne({
hourly_pay: "$15",
name: "Elon",
ssn: "562-48-5384",
weekly_hours: 100,
// We also support multi-insert using collection.insert()
// See
// Search by a single field Or many!
var employee = await collection.findOne({
ssn: "562-48-5384",
// We also support find(), findById()
// See
// Returns the matching document
// Prints the above added JSON document
// Update a document
var updatedEmployee = await collection.update(
{ ssn: "562-48-5384" },
{ $set: { hourly_pay: '$100' } }
// We also support updateMany(), findOneAndUpdate()
// See
// Returns the updated document
// Prints the updated JSON document
await collection.close(); // Collection will be closed.
await aviondb.drop(); // Drops the database
await aviondb.close(); // Closes all collections and binding database.
await ipfs.stop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment