Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    retain-httppublic

    retain-http

    Retain REST webservice plugin

    Build Status Coverage Status

    Example

    To start saving the Retain data in a REST webservice, simply inject the plugin into the Model.

    var retain = require("retain");
    var retainAjax = require("retain-http");
     
    var Movies = retain();
     
    Movies.use(retainAjax, {
          rest: "http://localhost:3000/movies"
        })

    Installation

    npm install retain-http

    Client version

    If you want you use retain-http in the browser, there are 2 options:

    • If your bundler have implemented the package.son browser spec, just require the file using the require signature:

       
      require("retain-http");
    • Otherwise, require the lib/client.js file using the CJS signature

      You can map the retain-http name to the lib/client.js file using your bundler mapping option, so you can require it using the default signature require('retain-http')

    Config

    • rest: REST URL that will be used to save the data.
    • search: URL that will be used to search the data (sending the attributes filter as parameter).

    Creating a plugin

    Retain use Promises internally to transfer data between the plugins.

    To create a plugin, it is necessary to implement each of the following Retain methods.

    • new
    • all
    • set
    • find
    • remove

    Each of theses methods must return a promise.

    Tests

    To run the tests in the server:

    make test

    To run the tests in the browser:

    Initialize the server where the data will be requested:

    make server

    Initialize the server to see the tests outputs

    make test-browser

    Visit localhost:4000/ in the browser.

    install

    npm i retain-http

    Downloadsweekly downloads

    0

    version

    0.2.4

    license

    MIT

    repository

    github.com

    last publish

    collaborators

    • avatar