SapphireDb logo SapphireDb

Get started - Setup JS client

sapphiredb is a client implementation for Javascript. It also works with NodeJs.

Installation

Install package

To install the package execute the following command in your console

You can find the project here: https://www.npmjs.com/package/sapphiredb

Create SapphireDb instace

\f:(typescript:app.module.ts) var sapphiredb = require('sapphiredb');\n\n var db = new sapphiredb.SapphireDb({\n \tserverBaseUrl: 'localhost:5000',\n \tuseSsl: false,\n \tapiKey: 'webapp',\n \tapiSecret: 'pw1234'\n });\n\n db.collection('demo.entries').values().subscribe(function (values) {\n \tconsole.log(values);\n });

Use websockets on NodeJs

sapphiredb also works in a NodeJs application. It will use polling as communication strategy by default. If you want to use websockets you have to install an external library for that.

\f:(typescript:app.module.ts) var sapphiredb = require('sapphiredb');\n\n var ws = require('ws');\n WebSocket = ws;\n\n var db = new sapphiredb.SapphireDb({\n \tserverBaseUrl: 'localhost:5000',\n \tuseSsl: false,\n \tapiKey: 'webapp',\n \tapiSecret: 'pw1234'\n });\n\n db.collection('demo.entries').values().subscribe(function (values) {\n \tconsole.log(values);\n });

Compatibility

Browser/EngineWebsocketSSEPolling
Chrome
Firefox
Opera
Edge
Internet Explorer 11
NodeJs

Technology support

JS, NodeJs, React, Svelte ...

Example

You can also check out the example projects:
NodeJs Example
React Example
Svelte Example

Done

Your SapphireDb-client should now work.

Start using it by querying data

This website uses Google Analytics. If you want to disable it just unselect the option: