Last active
August 29, 2015 14:22
-
-
Save vicneanschi/1489c610a9006a956d95 to your computer and use it in GitHub Desktop.
RethinkDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create DB | |
r.dbCreate("blog"). | |
# create table | |
r.db('test').tableCreate('authors') | |
# insert | |
r.table('authors').insert(JSON) | |
# get all documents from table | |
r.table('authors'). | |
# filter | |
r.table('authors').filter(r.row('name').eq("William Adama")). | |
r.table('authors').filter(r.row('posts').count().gt(2)). | |
# get by PK | |
r.table('authors').get('7644aaf2-9928-4231-aa68-4e65e31bf219'). | |
# realtime feed | |
r.table('authors').changes(). | |
# update | |
r.table('authors').update({type: "fictional"}). | |
# update with filter | |
r.table('authors').filter(r.row("name").eq("Jean-Luc Picard")). | |
update({posts: r.row("posts").append({ | |
title: "Shakespeare", | |
content: "What a piece of work is man..."}) | |
# delete | |
r.table('authors'). | |
filter(r.row('posts').count().lt(3)). | |
delete(). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment