0.1.2 • Published 4 years ago

@pamlight/client v0.1.2

Weekly downloads
-
License
ISC
Repository
github
Last release
4 years ago

Pamlight Client SDK

Pamlight is a service for managing realtime connections to your database with whatever technology it is powered by. This tool (Client SDK) is used to connect from client domains to pamlight endpoints at a high level.

Support/Compatibility

  • Angular - Supports Angular 2+
  • React
  • Vue

Getting started

For more detailed instructions and guides on how Pamlight works, see our official documentations here as well as creating new projects.

Installation

Install pamlight client sdk via npm by running the following command:

npm install @pamlight/client

Setup

import { PamlightClient } from '@pamlight/client';

const config = {
    projectId: <PROJECT_ID>
};
const client = new PamlightClient(config);
client.connect().then(() => {
    console.log('Pamlight connected successfully');
}).catch(err => {
    throw Error(err);
});

sync data from database

Syncing data changes from database is a straight forward process. This is done by calling sync method on the connected client and passing the payload which contains information required by the server to generate query data from. The result of sync method call is an observable of the data matched by the query generated by the server based on the payload passed to it. Read more here to see how data is passed between client and server.

const payload = { docId: '123' };
client.sync(<ROUTE_ID>, payload).subscribe(data => {
    console.log('Data received ', data);
}, err => {
    throw Error(`Pamlight sync error ${err}`);
});

write data to database

Writing data to your database is by calling the write method on the connected client object.

const payload = {
    docId: '12345',
    data: {name: 'Harry James}
};
client.write(<ROUTE_ID>, payload, true).subscribe(data => {
    console.log('Write operation completed');
});

Further Reading

For further reading and information, check more advanced read operations as well as advanced write operations

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

5 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago