0.3.0 • Published 7 months ago

surrealdb.node v0.3.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

surrealdb.node

The official SurrealDB library for Node.js.

npm.io npm.io npm.io

SurrealDB is an end-to-end cloud-native database designed for modern applications, including web, mobile, serverless, Jamstack, backend, and traditional applications. With SurrealDB, you can simplify your database and API infrastructure, reduce development time, and build secure, performant apps quickly and cost-effectively.

Key features of SurrealDB include:

  • Reduces development time: SurrealDB simplifies your database and API stack by removing the need for most server-side components, allowing you to build secure, performant apps faster and cheaper.
  • Real-time collaborative API backend service: SurrealDB functions as both a database and an API backend service, enabling real-time collaboration.
  • Support for multiple querying languages: SurrealDB supports SQL querying from client devices, GraphQL, ACID transactions, WebSocket connections, structured and unstructured data, graph querying, full-text indexing, and geospatial querying.
  • Granular access control: SurrealDB provides row-level permissions-based access control, giving you the ability to manage data access with precision.

View the features, the latest releases, the product roadmap, and documentation.

// import as ES module or common JS
import {Surreal} from 'surrealdb.node';
const {Surreal} = require('surrealdb.node');

const db = new Surreal();

// use in-memory database
await db.connect('memory');
// connect to database server
await db.connect('ws://127.0.0.1:8000');
// use rocksdb file
await db.connect(`rocksdb://${process.cwd()}/test.db`);

// Select a specific namespace / database
await db.use({ ns: "test", db: "test" });

// Create a new person with a random id
let created = await db.create("person", {
    title: "Founder & CEO",
    name: {
        first: "Tobie",
        last: "Morgan Hitchcock",
    },
    marketing: true,
    identifier: Math.random().toString(36).substr(2, 10),
});

// Update a person record with a specific id
let updated = await db.merge("person:jaime", {
    marketing: true
});

// Select all people records
let people = await db.select("person");

// Perform a custom advanced query
let groups = await db.query(
    "SELECT marketing, count() FROM type::table($table) GROUP BY marketing",
    {
        table: "person",
    },
);

// Delete all people upto but not including Jaime
let deleted = await db.delete("person:..jaime");

// Delete all people
await db.delete("person");

Supported targets

Tripplesupportedrocksdb supportreason
aarch64-apple-darwinx
aarch64-linux-android
aarch64-unknown-linux-gnu
aarch64-unknown-linux-muslx
aarch64-pc-windows-msvcxxring build fails
armv7-unknown-linux-gnueabihfxxpsm build fails
x86_64-unknown-linux-muslx
x86_64-unknown-freebsdx
i686-pc-windows-msvc
armv7-linux-androideabi
universal-apple-darwix