DEV Community

Morris Janatzek
Morris Janatzek

Posted on • Originally published at morrisj.net

New version of SapphireDb with NodeJs support

GitHub logo SapphireDb / sapphiredb-js

Client for SapphireDb, a self-hosted, easy to use realtime database for Asp.Net Core and EF Core

SapphireDb now has got a new client implementation that is compatible with any JS client and also compatible with NodeJs. The npm-package is called sapphiredb.

Story behind

A few days ago I posted an article on HackerNews to advertise a framework I created. The name of it is SapphireDb, it is an extension for Asp.Net Core and EF Core and enables you to easily create self hosted applications with realtime data synchronization. It should serve as alternative to firebase realtime database/firestore.

I got plenty of feedback including a few recommendations like moving the code base of the client implementation to a separate project. I totally agree to that point and decided to do so. At that moment SapphireDb only had a client implementation for Angular.

The process was not that complicated but I had to change all references to Angular specific things to a more generic API. I decided to use axios instead of Angulars HttpClient and it works fine. Also using direct inject of dependency instances instead of Angulars Dependency injection was pretty easy. I only decided to keep ng-packagr as build tool for the client library.

NodeJs example

npm install sapphiredb rxjs axios -S
var sapphiredb = require('sapphiredb');

var db = new sapphiredb.SapphireDb({
    serverBaseUrl: 'localhost:5000',
    useSsl: false,
    apiKey: 'webapp',
    apiSecret: 'pw1234'
});

db.collection('demo.entries').values().subscribe(function (values) {
    console.log(values);
});

Changes for ng-sapphiredb

Because I moved the complete code base out of the project because I don't want to maintain the same code in two places you have to install sapphiredb along with ng-sapphiredb when using it.

npm install ng-sapphiredb sapphiredb axios -S

Check out the documentation to learn more: https://sapphire-db.com/

GitHub logo SapphireDb / sapphiredb-js

Client for SapphireDb, a self-hosted, easy to use realtime database for Asp.Net Core and EF Core

Oldest comments (0)