Erlang Mailing Lists

Author Message

<  Erlyweb mailing list  ~  [REQ] More info on model usage

dmitriid
Posted: Mon Jan 14, 2008 4:54 pm Reply with quote
User Joined: 17 Aug 2006 Posts: 213
If anoyone could be so kind as to write more info on how models could be
used Smile

I know that yo can pass interesting tuples to create all kinds of
queries. And that you can use conditions in find() methods (correct me
if I'm wrong). But it gets really tiresome trying to figure it all out
by trial and error.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message
dmitriid
Posted: Mon Jan 14, 2008 5:05 pm Reply with quote
User Joined: 17 Aug 2006 Posts: 213
Dmitrii 'Mamut' Dimandt wrote:
> If anoyone could be so kind as to write more info on how models could be
> used Smile
Deduced some info from Yariv's introduction at
http://yarivsblog.com/articles/2006/09/16/introducing-erlsql-easy-expression-and-generation-of-sql-statements-in-erlang/

conditions in find can be used like this:
Entries = entry:find({id, '=', '12'})

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message
dmitriid
Posted: Fri Jan 18, 2008 11:28 am Reply with quote
User Joined: 17 Aug 2006 Posts: 213
I'm still at qite a loss Smile

Here's a table that I have:
Quote:
page
------
id
title
url_title
Having erlyweb_magic on and running m(page), I get this:

add_related_many_to_many/3
View user's profile Send private message
Guest
Posted: Mon Jan 21, 2008 8:03 am Reply with quote
Guest
On Jan 18, 2008 3:27 AM, Dmitrii 'Mamut' Dimandt <dmitriid@gmail.com> wrote:
>
> I'm still at qite a loss Smile
>
> Here's a table that I have:
>
> page
> ------
> id
> title
> url_title
> Having erlyweb_magic on and running m(page), I get this:
>
> add_related_many_to_many/3 find_related_many_range/6
> after_delete/1 find_related_many_to_many/5
> after_fetch/1 find_related_many_to_one/5
> after_save/1 find_related_one_to_many/3
> aggregate/4 find_with/1
> aggregate_related_many/6 get/2
> aggregate_related_many_to_many get_module/1
> aggregate_related_many_to_one/ get_pk_fk_fields/0
> avg/3 get_pk_fk_fields2/0
> avg/1 id/1
> avg/2 id/2
> avg_with/2 increment/1
> before_delete/1 increment/2
> before_save/1 insert/1
> count/0 is_new/1
> count/3 is_new/2
> count/2 is_related/3
> count/1 max/3
> count_with/2 max/1
> db_field/1 max/2
> db_field_names/0 max_with/2
> db_field_names_bin/0 min/3
> db_field_names_str/0 min/1
> db_fields/0 min/2
> db_num_fields/0 min_with/2
> db_pk_fields/0 module_info/0
> db_table/0 module_info/1
> decrement/1 new/0
> decrement/2 new/2
> delete/1 new_from_strings/1
> delete_all/0 new_with/1
> delete_id/1 new_with/2
> delete_where/1 relations/0
> do_delete/1 remove_related_many_to_many/3
> do_save/1 remove_related_many_to_many_all/5
> driver/0 save/1
> field_from_string/2 set/3
> field_names_for_query/0 set_fields/2
> field_names_for_query/1 set_fields/3
> field_to_iolist/2 set_fields_from_strs/2
> field_to_iolist/1 set_related_one_to_many/3
> fields/0 stddev/3
> find/2 stddev/1
> find/1 stddev/2
> find/0 stddev_with/2
> find_first/2 sum/3
> find_first/0 sum/1
> find_first/1 sum/2
> find_first_with/1 sum_with/2
> find_id/1 table/0
> find_max/3 title/2
> find_max/1 title/1
> find_max/2 to_iolist/1
> find_max_with/2 to_iolist/2
> find_range/4 transaction/1
> find_range/2 type_field/0
> find_range/3 update/1
> find_range_with/3 update/2
> find_related_many_first/4 url_title/2
> find_related_many_max/5 url_title/1
>
>
> Some of these I understand and know how to use. Like title/1, id/1,
> url_title/1
> Others I understand, but I don't know how to use: all the *_with functions,
> id/2 (and other field_name/2)
> And same I don't understand at all. Like find_related_many_first/4
>
> I also have a page_section table:
>
> page_section
> -------------
> id
> section_order
> section_text
> page_id
> How do I tell page_section that page_id is a many-to-one relationship to
> the page table?

in page_section.erl, add this function

relations() ->
[{many_to_one, [page]}].


>
> I know the enlightenment is just around the corner, but I'm not just there
> yet Smile

Did you read the documentation for erlydb_base? It should explain and
give examples for everything you need.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
dmitriid
Posted: Mon Jan 21, 2008 8:33 am Reply with quote
User Joined: 17 Aug 2006 Posts: 213
Yariv Sadan wrote:
Quote:
On Jan 18, 2008 3:27 AM, Dmitrii 'Mamut' Dimandt <dmitriid@gmail.com> (dmitriid@gmail.com) wrote: [/code] in page_section.erl, add this function relations() -> [{many_to_one, [page]}]. [/code]
I thought it would be easy! Smile
Quote:
[/code]
Quote:
I know the enlightenment is just around the corner, but I'm not just there yet Smile [/code]
[/code]
For some odd reason I skipped that section. I thought it was going to deal with some techinical data and such Smile

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "erlyweb" group.
To post to this group, send email to erlyweb@googlegroups.com
To unsubscribe from this group, send email to erlyweb-unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/erlyweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Post recived from mailinglist
View user's profile Send private message

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum