GithubHelp home page GithubHelp logo

tinysou-node's Introduction

tinysou-node

Build Status

Tinysou node client

Installation

npm install tinysou

Usage

var Tinysou = require('tinysou')
var tinysou = new Tinysou('your_token')

Engine

List:

tinysou.engines.list(function(err, res) {
  console.log(res);
});

Create:

tinysou.engines.create({
  name: 'blog',
  display_name: 'Blog'
}, function(err, res) {
  console.log(res);
});

Get:

tinysou.engines.get('blog', function(err, res) {
  console.log(res);
});

Update:

tinysou.engines.update('blog', {
  display_name: 'My Blog'
}, function(err, res) {
  console.log(res);
});

Delete:

tinysou.engines.delete('blog', function(err, res) {
  console.log(res);
});

Collection

List

tinysou.collections.list('blog', function(err, res) {
  console.log(res);
});

Create

tinysou.collections.create('blog', {
  name: 'posts',
  field_types: {
    title: 'string',
    tags: 'string',
    author: 'enum',
    date: 'date',
    body: 'text'
  }
}, function(err, res) {
  console.log(res);
});

Get

tinysou.collections.get('blog', 'posts', function(err, rest) {
  console.log(res);
});

Delete

tinysou.collections.delete('blog', 'posts', function(err, res) {
  console.log(res);
});

Document

List

tinysou.documents.list('blog', 'posts', function(err, res) {
  console.log(res);
});

Create

tinysou.documents.create('blog', 'posts', {
  title: 'My First Post',
  tags: ['news'],
  author: 'Author',
  date: '2014-08-16T00:00:00Z',
  body: 'Tinysou start online today!'
}, function(err, res) {
  console.log(res);
});

Get

tinysou.documents.get('blog', 'posts', documentId, function(err, res) {
  console.log(res);
});

Update

tinysou.documents.update('blog', 'posts', documentId, {
  title: 'My First Post',
  tags: ['news'],
  author: 'Author',
  date: '2014-08-16T00:00:00Z',
  body: 'Tinysou start online today!'
}, fucntion(err, res) {
  console.log(res);
});

Delete

tinysou.documents.delete('blog', 'posts', documentId, function(err, res) {
  console.log(res);
});

Search

Search in collections

tinysou.search('blog', {
  q: 'tinysou',
  c: 'posts'
  page: 0,
  per_parge: 10,
  filter: {
    range: {
      field: "date",
      from: "2014-07-01T00:00:00Z",
      to: "2014-08-01T00:00:00Z"
    }
  },
  sort:{
    field: "date",
    order: "asc",
    mode: "avg"
  }
}, function(err, res) {
  console.log(res);
});

Autocomplete

Autocomplete in collections

tinysou.autocomplete('blog', {
  q: 'tinys',
  c: 'posts'
  page: 0,
  per_parge: 10,
  filter: {
    range: {
      field: "date",
      from: "2014-07-01T00:00:00Z",
      to: "2014-08-01T00:00:00Z"
    }
  },
  sort: {
    field: "date",
    order: "asc",
    mode: "avg"
  }
}, function(err, res) {
  console.log(res);
});

Examples

See examples

Contributing

  1. Fork it ( https://github.com/tinysou/tinysou-node/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

tinysou-node's People

Contributors

fellesy avatar graygrey avatar hemslo avatar yandy avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  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.