JavaScript Client API

Complete API reference for the NexaDB JavaScript/Node.js client library.

Installation

Terminal
$npm install nexaclient

Quick Example

example.jsnexaclient
const NexaClient = require('nexaclient');

const db = new NexaClient({
  host: 'localhost',
  port: 6970,
  username: 'root',
  password: 'nexadb123'
});

await db.connect();

const user = await db.create('users', {
  name: 'Alice',
  email: 'alice@example.com'
});

console.log(user);

await db.disconnect();

Core Methods

connect()

Establish connection to NexaDB server

await db.connect()

create(collection, data)

Create a new document in a collection

const doc = await db.create('users', { name: 'John' })

get(collection, id)

Retrieve a document by its ID

const user = await db.get('users', 'doc_123')

update(collection, id, data)

Update an existing document

await db.update('users', 'doc_123', { name: 'Jane' })

delete(collection, id)

Delete a document by its ID

await db.delete('users', 'doc_123')

query(collection, filter, options)

Query documents with filters

const results = await db.query('users', { age: { $gt: 18 } }, { limit: 10 })