Tinysou node client
npm install tinysou
var Tinysou = require('tinysou')
var tinysou = new Tinysou('your_token')
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);
});
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);
});
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 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 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);
});
See examples
- Fork it ( https://github.com/tinysou/tinysou-node/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request