npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

surrealdb.wasm

v1.0.0-beta.9

Published

WebAssembly driver for SurrealDB

Downloads

1,155

Readme

surrealdb.wasm

The official SurrealDB library for WebAssembly.

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, and documentation.

  • [x] Can be used as an embedded database
  • [x] Consistent API across all supported protocols and storage engines
  • [x] Interfaces with the JavaScript SDK to have a common interface between all connections
  • [x] Asynchronous, lock-free connections

It is important to know what the surrealdb.wasm library is, and what it is not:

  • It's a library targeted to browsers, not NodeJS.
  • It is targeted towards ES modules (import statements), not CommonJS (require function).

Importing the module

Here is an example on how to import this package, and how to connect it to the JavaScript SDK

import { Surreal } from 'surrealdb.js';
import { surrealdbWasmEngines } from 'surrealdb.wasm';

const db = new Surreal({
	engines: surrealdbWasmEngines(),
});

// Can now use the JS SDK as you normally would, 
// but with added mem and indxdb protocols

This library enables simple and advanced querying of an embedded or remote database. By default, all remote connections to SurrealDB are made over WebSockets, and automatically reconnect when the connection is terminated.

import { Surreal } from 'surrealdb.js';
import { surrealdbWasmEngines } from 'surrealdb.wasm';

const db = new Surreal({
	engines: surrealdbWasmEngines(),
});

// Connect to an in-memory database
await db.connect("mem://");
// Connect to an indexeddb database
await db.connect("indxdb://demo");

// Select a specific namespace / database
await db.use({ 
	namespace: "test", 
	database: "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,
});

// Update a person record with a specific id
let updated = await db.merge(new RecordId('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 $tb GROUP BY marketing",
	{
		tb: new Table("person"),
	},
);