README.md in rasti-db-2.0.1 vs README.md in rasti-db-2.1.0

- old
+ new

@@ -91,11 +91,11 @@ ```ruby User = Rasti::DB::Model[:id, :name, :posts, :comments, :person] Post = Rasti::DB::Model[:id, :title, :body, :user_id, :user, :comments, :categories] Comment = Rasti::DB::Model[:id, :text, :user_id, :user, :post_id, :post] Category = Rasti::DB::Model[:id, :name, :posts] -Person = Rasti::DB::Model[:document_number, :first_name, :last_name, :birth_date, :user_id, :user] +Person = Rasti::DB::Model[:document_number, :first_name, :last_name, :full_name, :birth_date, :user_id, :user] Language = Rasti::DB::Model[:id, :name, :people] ``` ### Collections @@ -109,14 +109,14 @@ class Posts < Rasti::DB::Collection many_to_one :user many_to_many :categories one_to_many :comments - query :created_by do |user_id| + query :created_by do |user_id| where user_id: user_id end - + query :entitled, -> (title) { where title: title } query :commented_by do |user_id| chainable do dataset.join(qualify(:comments), post_id: :id) @@ -142,10 +142,14 @@ set_foreign_key :document_number set_model Person many_to_one :user many_to_many :languages + + computed_attribute :full_name do + Rasti::DB::ComputedAttribute.new Sequel.join([:first_name, ' ', :last_name]) + end end class Languages < Rasti::DB::Collection set_data_source_name :other @@ -208,9 +212,13 @@ 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, ...] + +posts.each { |post| do_something post } # Iterate posts loading all at first +posts.each(batch_size: 1000) { |post| do_something post } # Iterate posts loading in batches +posts.each_batch(size: 1000) { |posts| do_something posts } # Iterate batches of posts ``` ### Natural Query Language ```ruby posts.nql('id = 1') # => Equal