README.md in rasti-db-1.4.0 vs README.md in rasti-db-1.5.0
- old
+ new
@@ -2,11 +2,10 @@
[![Gem Version](https://badge.fury.io/rb/rasti-db.svg)](https://rubygems.org/gems/rasti-db)
[![Build Status](https://travis-ci.org/gabynaiman/rasti-db.svg?branch=master)](https://travis-ci.org/gabynaiman/rasti-db)
[![Coverage Status](https://coveralls.io/repos/github/gabynaiman/rasti-db/badge.svg?branch=master)](https://coveralls.io/github/gabynaiman/rasti-db?branch=master)
[![Code Climate](https://codeclimate.com/github/gabynaiman/rasti-db.svg)](https://codeclimate.com/github/gabynaiman/rasti-db)
-[![Dependency Status](https://gemnasium.com/gabynaiman/rasti-db.svg)](https://gemnasium.com/gabynaiman/rasti-db)
Database collections and relations
## Installation
@@ -106,11 +105,11 @@
query :commented_by do |user_id|
chainable do
dataset.join(with_schema(:comments), post_id: :id)
.where(with_schema(:comments, :user_id) => user_id)
- .select_all(with_schema(:posts))
+ .select_all(:posts)
.distinct
end
end
end
@@ -160,20 +159,52 @@
```ruby
posts.all # => [Post, ...]
posts.first # => Post
posts.count # => 1
+
posts.where(id: [1,2]) # => [Post, ...]
posts.where{id > 1}.limit(10).offset(20) } # => [Post, ...]
-posts.graph(:user, :categories, 'comments.user') # => [Post(User, [Categories, ...], [Comments(User)]), ...]
-posts.created_by(1) # => [Post, ...]
-posts.created_by(1).entitled('...').commented_by(2) # => [Post, ...]
-posts.with_categories([1,2]) # => [Post, ...]
+
posts.where(id: [1,2]).raw # => [{id:1, ...}, {id:2, ...}]
posts.where(id: [1,2]).primary_keys # => [1,2]
posts.where(id: [1,2]).pluck(:id) # => [1,2]
posts.where(id: [1,2]).pluck(:id, :title) # => [[1, ...], [2, ...]]
+
+posts.created_by(1) # => [Post, ...]
+posts.created_by(1).entitled('...').commented_by(2) # => [Post, ...]
+posts.with_categories([1,2]) # => [Post, ...]
+
+posts.graph(:user, :categories, 'comments.user') # => [Post(User, [Categories, ...], [Comments(User)]), ...]
+
posts.join(:user).where(name: 'User 4') # => [Post, ...]
+
+posts.select_attributes(:id, :title) # => [Post, ...]
+posts.exclude_attributes(:id, :title) # => [Post, ...]
+posts.all_attributes # => [Post, ...]
+
+posts.graph('user.person').select_graph_attributes(user: [:id], 'user.person': [:last_name, :user_id]) # => [Post, ...]
+posts.graph('user.person').exclude_graph_attributes(user: [:name], 'user.person': [:first_name, :last_name]) # => [Post, ...]
+posts.graph('user.person').all_graph_attributes('user.person') # => [Post, ...]
+```
+### Natural Query Language
+
+```ruby
+posts.nql('id = 1') # => Equal
+posts.nql('id != 1') # => Not equal
+posts.nql('title: My post') # => Include
+posts.nql('title !: My post') # => Not include
+posts.nql('title ~ My post') # => Insensitive like
+posts.nql('id > 1') # => Greater
+posts.nql('id >= 1') # => Greater or equal
+posts.nql('id < 10') # => Less
+posts.nql('id <= 10') # => Less or equal
+
+posts.nql('id = 1 | id = 2') # => Or
+posts.nql('id > 1 & title: "My post"') # => And
+posts.nql('(id > 3 & id < 10) | title: "My post"') # => Precedence
+
+posts.nql('comments.user.person.document_number = 7') # => Nested
```
## Development
Rasti::DB uses treetop to perform queries using natural language. To recompile the syntax, simply run the following command in `lib/rasti/db/nql`: