multiples order_by in embbeds_manu not work?

22 views
Skip to first unread message

Rodrigo Mendonça

unread,
Aug 25, 2014, 3:20:19 PM8/25/14
to mon...@googlegroups.com
School embeds_many :students

In rails console:
School.first.students.order_by(:name.asc, :email.desc)

Works with name. but why ordering from second field (email) not work?? It's a bug?

--

Rodrigo Mendonça

unread,
Aug 26, 2014, 7:13:59 AM8/26/14
to mon...@googlegroups.com
Conclusion:
embeds_many don't order multiples fields and has_many can be depreciate in futures versions. Was a mistake includes mongo in my rails application??

Any ideas?

With has_many i don't have this problem, but reading stuff from mongoid documentation i saw this:
Relational Associations

Mongoid provides relational-style associations as a convenience for application developers who are used to dealing with relational databases, but we do not recommend you use these extensively.

MongoDB provides no transactions, and no join support, so it is impossible to ensure that the database is kept in a consistent state with regards to referencing documents from one collection to another. Also, without support for joins, you will find that the number of database queries executed grows in order to retrieve documents with their associations, and can have a huge affect on performance since this is not where MongoDB's power lies.

If you find that you have more relational associations in your application than embedded ones, it is recommended that you not use MongoDB and move to a relational database. Also, you will probably find this feature removed in future versions of Mongoid, in order to not allow developers to use the database in an incorrect fashion.


--

Reply all
Reply to author
Forward
0 new messages