Quick Start
Create your first collection, add attributes, and store documents in minutes.
Get a Document schema up and running with collections and documents. This guide covers the essentials of setting up your database and interacting with it using the Client SDK.
Create a Schema & Collection
Schema and Collection management are administrative tasks. Please perform these steps in the Nuvix Console.
- Log in to the Nuvix Console.
- Navigate to Database and click Create Schema.
- Name:
my_app - Type: Document
- Name:
- Click on your new schema and select Create Collection.
- Name:
Tasks - Collection ID:
tasks
- Name:
Add Attributes
Define the structure of your documents by adding attributes in the Attributes tab of your collection.
- String Attribute: Key
title, Size255, Required. - Boolean Attribute: Key
completed, Defaultfalse. - Datetime Attribute: Key
dueDate, Optional.
Initialize the SDK
Install and configure the Nuvix Client SDK in your application.
npm install @nuvix/clientimport { Client } from '@nuvix/client';
const nx = new Client()
.setEndpoint('https://api.nuvix.in/v1')
.setProject('<PROJECT_ID>'); // Your Project IDCreate Documents
Store data in your collection using the Fluent API.
import { ID } from '@nuvix/client';
// Reference the collection
const tasks = nx.database.schema('my_app').collection('tasks');
// Create a document
const document = await tasks.create(ID.unique(), {
title: 'Write documentation',
completed: false,
dueDate: '2024-12-31T23:59:59.000Z'
});
console.log('Document created:', document.$id);Query Documents
Retrieve documents with filters, sorting, and pagination using chainable methods.
// List all documents
const allTasks = await nx.database
.schema('my_app')
.collection('tasks')
.find();
console.log('Total:', allTasks.total);
// Filter incomplete tasks
const incompleteTasks = await nx.database
.schema('my_app')
.collection('tasks')
.equal('completed', false)
.orderDesc('$createdAt')
.limit(10)
.find();Update and Delete
Modify or remove documents by their ID.
const tasks = nx.database.schema('my_app').collection('tasks');
// Update a document
await tasks.update('<DOCUMENT_ID>', {
completed: true
});
// Delete a document
await tasks.delete('<DOCUMENT_ID>');You now have a working database with collections and documents. Check out the guides below to learn more.
How is this guide?
Last update: