Giter Site home page Giter Site logo

challenges.fortune-client's Introduction

Fortune Client

Library for interacting with multiple instances of Fortune

Note: this documentation is hopelessly out of date. Update is in the works but for now you'd be better off looking at the tests if you need examples.

Initialisation

var client = require("fortune-client")([ fortuneInstanceA, fortuneInstanceB ]);

Methods

Get

getResource(id, options)
getResources(query,options)

Gets a single,a set of or all documents of a given resource depending on whether the id is a single number, an array or a query. Returns a promise resolved with the requested resource data.

Example:

client.getUsers({firstName: "John"}).then(function(data){
  ...
});

Create

createResource(document, options)
createResources(arrayOfDocuments,options)

Creates a new document. Returns a promise resolved with then new created document.

Example:

client.createUser({ name: "Bob", email: "[email protected]" })

Destroy

destroyResource(id, options)
destroyResources(query, options)

Destroys a single, a set of or all documents of a given resource depending on whether the id is a single number, an array or a query.

Example:

client.destroyUsers(["Alice", "Bob", "Charlie"])

Replace

replaceResource(id, document, options)
replaceResources(arrayOfIds, document, options)

Replaces the resource data for a given id with a provided document

Example:

client.replaceUser("Joe", { name: "Alice", sexChangedOn: "2011-10-09"})

Update

udpateResource(id, data, options)
udpateResources(arrayOfIds, data, options)

Updates a given resource.

Example:

client.udpateUser("Joe", {op: "add", path: "/users/0/houses/-", value: "1 Elm Row"})

Options

client.getResources(null, {
  headers: { "content-type": "application/json" }, // set any headers on the underlying request
  fields: ["firstName", "lastName"],
  include: ["ref1", "ref2"]
})

#Running demo

From fortune-client root folder run

  • git submodule init
  • git submodule update
  • npm install
  • cd demo/fortune
  • npm install
  • cd ../..
  • node demo/example-inproc.js

challenges.fortune-client's People

Contributors

jesuscript avatar eugenekostrikov avatar dmskr avatar lautarodragan avatar bbraithwaite avatar kabaros avatar mjtodd avatar hingsta avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.