Raw ID from Boss DB model?

46 views
Skip to first unread message

aloharich

unread,
Dec 29, 2014, 4:51:38 PM12/29/14
to chica...@googlegroups.com
Using a model with BossDB, the "id" appears to prepend the table name,

So   Model:id()  returns "model-1" for example.

Some of our relationships can't be modeled completely with the ORM, so additional raw queries are needed using the actual ID (ie 1, not model-1).

Are there any methods or ways to configure the model to provide access to the raw id (versus having to hack the :id() result to parse it).

Evgeny M

unread,
Dec 31, 2014, 5:20:49 AM12/31/14
to chica...@googlegroups.com, ri...@electricimp.com
Afaik there are no such mehods

Just add a method 
  
 int_id() -> 
       [_, IId] = string:tokens(Id, "-"), 
       list_to_integer(IId).

or something like this to your models.

вторник, 30 декабря 2014 г., 0:51:38 UTC+3 пользователь aloharich написал:

Graeme Defty

unread,
Dec 31, 2014, 5:39:03 AM12/31/14
to chica...@googlegroups.com
This may not be important to you, but bear in mind that record Ids are an opaque data element, and your code will break with other databases. I use the whole string as the record key in Mnesia, and I suspect the (at least some of) the non-SQL databases do the same thing.

Cheers,

g



--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/d933fe7a-b26d-4dbc-9aa2-d5a4732e0d4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Welton

unread,
Jan 1, 2015, 8:39:09 AM1/1/15
to chica...@googlegroups.com
On Wed, Dec 31, 2014 at 11:39 AM, Graeme Defty <graeme...@gmail.com> wrote:
>
> This may not be important to you, but bear in mind that record Ids are an opaque data element, and your code will break with other databases. I use the whole string as the record key in Mnesia, and I suspect the (at least some of) the non-SQL databases do the same thing.

I don't think it's possible to write a complex application without
going to SQL (or whatever low-level thing people use for other
systems), as things currently stand.

--
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/

Graeme Defty

unread,
Jan 1, 2015, 9:48:01 AM1/1/15
to chica...@googlegroups.com
I am not sure what you would call complex, but my application has 43 models (tables) and 23 controllers, all on Mnesia and of course all without SQL.

I suspect that I am paying a price in performance, but my application is such that scalability is not a major issue.


BTW I would be interested to know if anyone else is using Mnesia.



--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss...@googlegroups.com.
Visit this group at http://groups.google.com/group/chicagoboss.
Reply all
Reply to author
Forward
0 new messages