model associations

24 views
Skip to first unread message

Gökçe Asova

unread,
Jan 14, 2015, 10:23:56 AM1/14/15
to ceq...@googlegroups.com
Hi,

My apologies if my question looks like stupid but I'm newbie on Cequel and NoSQL database logic. 

I would like a concrete example on how to migrate my active record logic into NoSQL

I've choosen cassandra and then cequel for my project.


The active record definition is as follows:

I have a blog that has following models:
  • post
  • author
  • comment
post model is defined with :
  • belongs_to :author
  • has_many :comments
author model :
  • has_many :posts

What I want is to do the same with Cassandra / Cequel 

I understood the logic in the model definiton with the cequel documentation on github, 
but can't figure out how to handle associations inside views and controllers to manage relations between post and author for example.

How should I define authors collection in the post _form.html.erb file ?

Also in posts/index.html.erb file how can I display and get associated author names...?

is it exactly the same than with active records? 


Kind Regadrs







Matthew A. Brown

unread,
Jan 14, 2015, 1:07:17 PM1/14/15
to Gökçe Asova, ceq...@googlegroups.com
Hi Gökçe,

You'll probably want to use a secondary index to manage the author-post relationship, since the author is not the natural “parent” of the post (the blog is). Unfortunately Cequel does not currently support relationships based on secondary indexes, but it's not too hard to hand-roll the basic functionality. You'd want something like this: https://gist.github.com/outoftime/e10ab2112edde79804b1

Let me know if that helps! Also if you need further clarification it would be helpful to see a gist of the basic structure of your models currently.

Mat

--
You received this message because you are subscribed to the Google Groups "Cequel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cequel+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Gökçe Asova

unread,
Jan 14, 2015, 4:03:37 PM1/14/15
to ceq...@googlegroups.com, go...@asova.com
Hi Mat, 

Thanks a lot that helped me.

I've succeeded making it work, I'm  learning slowly sequel and Cassandra... It looks great and powerful... 

Thanks a Lot.

Kind Regards.
Reply all
Reply to author
Forward
0 new messages