Skip to main content

Introduction

Easybase data operations are executed with the db() function. This function allows developers to create simple, yet powerful CRUD operations in code.

Access the db() function from the useEasybase() hook:

import { useEasybase } from 'easybase-react';

function MyComponent() {
const { db } = useEasybase();
return (
{/* ... */}
);
}

Basic usage

Start by specifying the table you would like to operate on as a parameter to db(). Here's an example that inserts one record to a table called CITIES when MyComponent mounts:

import { useEffect } from 'react';
import { useEasybase } from 'easybase-react';

function MyComponent() {
const { db } = useEasybase();

useEffect(() => {
db('CITIES').insert({ name: "Pittsburgh", visited: new Date() }).one()
.then(() => console.log("Success!"));
}, [])

return (
{/* ... */}
);
}

Be sure the data you are operating on has the same schema that you detailed in your Easybase table:

Database introduction 1

Remember, Easybase tables are highly scalable and can handle high amounts of throughput. All changes will be directly reflected in your tables, in real-time.