Skip to content

tinysou/tinysou-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tinysou-php

Tinysou PHP Client

Usage

$client = new TinySou('YOUR_TOKEN');

Engine

List:

$client->engines();

Create:

$client->create_engine(array(
  'name' => 'blog', 'display_name' => 'Blog'
  ));

Retrieve:

$client->engine('blog');

Update:

$client->update_engine('blog', array('display_name' => 'My Blog'));

Delete:

$client->delete_engine('blog');

Collection

List:

$client->collections('blog');

Create:

$client->create_collection('blog',
  array('name' => 'posts',
       'field_types' => array(
            'title' => 'string',
            'tags' => 'string',
            'author' => 'enum',
            'date' => 'date',
            'body' => 'text'
            )
        )
);

Retrieve:

$client->collection('blog', 'posts');

Delete:

$client->delete_collection('blog', 'posts');

Document

List:

$client->documents('blog', 'posts', array('page' => 0, 'per_page' => 20));

Create:

$client->create_document('blog', 'posts', array(
    'title' => 'My First Post',
    'tags' => ['news'],
    'author' => 'Author',
    'date' => '2014-08-16T00:00:00Z',
    'body' => 'Tinysou start online today!'
    )
);

Retrieve:

$client->document('blog', 'posts', '293ddf9205df9b36ba5761d61ca59a29');

Update:

$client->update_document('blog', 'posts', '293ddf9205df9b36ba5761d61ca59a29', array(
    'title' => 'First Post',
    'tags' => ['news'],
    'author' => 'Author',
    'date' => '2014-08-16T00:00:00Z',
    'body' => 'Tinysou start online today!'
    )
);

Delete:

$client->delete_document('blog', 'posts', '293ddf9205df9b36ba5761d61ca59a29');

Search

$client->search('blog', array(
    'q' => 'tinysou', 'c' => 'posts',
    'page' => 0, 'per_parge' => 10,
    'filter' => array(
            'range' => array(
                'field' => "date",
                'from' => "2014-07-01T00:00:00Z",
                'to' => "2014-08-01T00:00:00Z"
            )
        ),
    'sort' => array(
        'field' => "date",
        'order' => "asc",
        'mode' => "avg"
    )
  )
);

Autocomplete

$client->autocomplete('blog', array('q' => 't', 'c' => 'posts'));

Examples

See examples

Contributing

  1. Fork it ( https://github.com/tinysou/tinysou-php/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

Releases

No releases published

Packages

No packages published

Languages