22
33[ ![ Latest Stable Version] ( https://img.shields.io/npm/v/nymph-client-node.svg )] ( https://www.npmjs.com/package/nymph-client-node ) [ ![ Open Issues] ( https://img.shields.io/github/issues/sciactive/nymph-client-node.svg )] ( https://github.com/sciactive/nymph-client-node/issues ) [ ![ License] ( https://img.shields.io/github/license/sciactive/nymph-client-node.svg )] ( )
44
5- Nymph is an object data store that is easy to use in JavaScript and PHP.
5+ Nymph is an object data store for JavaScript and PHP.
66
77## Installation
88
9- You can install Nymph Node Client with NPM.
10-
119``` sh
1210npm install --save nymph-client-node
1311```
@@ -18,51 +16,28 @@ The Nymph client requires some browser globals that Node doesn't provide, so thi
1816
1917It also sets up Nymph.init to also call PubSub.init with your configs, so you don't need to set up PubSub yourself.
2018
21- ## Setting up Nymph in Node.js
19+ ## Usage
2220
23- <div dir =" rtl " >Quick Setup with NPM</div >
24-
25- ``` sh
26- npm install --save nymph-client-node
27- ```
28-
29- To use, require it as the Nymph object:
21+ To use, require it instead of ` nymph-client ` :
3022
3123``` js
32- const Nymph = require (' nymph-client-node' ). Nymph ;
24+ const { Nymph } = require (' nymph-client-node' );
3325```
3426
35- Or, if you need cookie support (like if you're using Tilmeld):
27+ Or, if you need cookie support (like, if you're using [ Tilmeld] ( http://tilmeld.org/ ) ):
3628
3729``` js
3830const NymphNode = require (' nymph-client-node' );
3931NymphNode .enableCookies ();
40- const Nymph = NymphNode . Nymph ;
32+ const { Nymph } = NymphNode;
4133```
4234
4335Then provide the options to Nymph.init:
4436
4537``` js
4638Nymph .init ({
4739 restURL: ' https://yournymphrestserver/path/to/your/rest.php' ,
48- pubsubURL: ' wss://yournymphpubsubserver:8080'
49- });
50- ```
51-
52- Now include your entity classes, such as ` Todo ` , and you can write queries and subscribe to them:
53-
54- ``` js
55- Nymph .getEntities ({' class' : Todo .class }, {' type' : ' &' , ' strict' : [' name' , ' Foobar' ]}).subscribe ((todos ) => {
56- console .log (" \n New Foobar Todo Updates: " , todos);
57- });
58-
59- const myTodo = new Todo ();
60- myTodo .set ({
61- name: " Foobar" ,
62- done: false
63- });
64- myTodo .save ().then (() => {
65- alert (" You've got new todos!" );
40+ pubsubURL: ' wss://yournymphpubsubserver'
6641});
6742```
6843
0 commit comments