Yes, I know how to create many to many relationships but nothing else. I did a google search and read official mongoid documentation but I didn’t anything about how to work with it. By work I mean inserting, updating, deleting, finding, counting…
For example, suppose I have 2 models (from documentation):
class Band
include Mongoid::Document
has_and_belongs_to_many :tags
end
class Tag
include Mongoid::Document
field :name, type: String
has_and_belongs_to_many :bands
end
What should I do to make all the operations I mentioned above?
P.S. I use Sinatra and mongoid 3.
Inserting
From the documentation table immediately following your sample models (plus my comment).
Finding
Also from the same table.
Updating
From the doc on persistence, modified for the band/tags example.
Counting
From the doc on querying, which also contains information useful for the other items here (also modified).
Deleting
This is from the persistence document also.
Lastly
All the information needed to work Mongoid is in the docs, which are actually very thorough and useful. There is definitely a lot, but you can make it through it in a couple hours.