The problem of boss_db:find

103 views
Skip to first unread message

Caiyun Deng

unread,
Jul 20, 2014, 11:45:06 AM7/20/14
to chica...@googlegroups.com
Hi!
boss_db:find(game_mark, [{account_id, equals, AccountId}, {game_id, equals, GameId}]).
It excute"SELECT * FROM game_marks WHERE game_id = 'game-5' AND account_id = 'account-1' AND  TRUE ORDER BY id ASC";
But i want it to excute"SELECT * FROM game_marks WHERE game_id = 5 AND account_id = 1 AND  TRUE ORDER BY id ASC"
Except this: 
[_Pre, TrueAccountId]" = string.tokens("account-5", "-").

Could you tell me is there other better method to do this?

Jesse Gumm

unread,
Aug 19, 2014, 6:01:44 PM8/19/14
to chica...@googlegroups.com
This is definitely a hairy situation, and trying to selectively parse
out the "account-1" could certainly lead to issues, since "account-1"
is a perfectly valid string.

I'm not sure the best way to handle this kind of situation.

Perhaps the simple solution, rather than manually tokenizing the
string each time would be a simple function like
boss_db:extract_id(Id), then you could at least use that.

Alternatively, supporting boss_db:find(game_mark, [{AccountId},
{Gameid}]) where AccountId (having the format "account-1"), gets
parsed out as {account_id, equals, IntegerID}.

That might be a reasonable option to add some brevity, though not
entirely sure what folks think of that.
> --
> 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/ee64417d-d7f3-43c4-a7f3-750267f240aa%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm

Avelino Puello

unread,
Sep 29, 2014, 11:00:05 AM9/29/14
to chica...@googlegroups.com
Hi Jesse,

I have a quick question here, I am using MongoDB adapter and I am finding an issue when doing a 

boss_db:find(post, [], [{limit,4},{offset,0},{order_by,timestamp}, descending]).

The issue is with the limit part, if I set limit to 1 will work find, it will return only 1 record, now if I set it to a number greater then 1 it will return all record in the DB.

Offset, Order_by and DES/ASC work perfectly fine.

I also tried boss_db:find(post, [], [{limit,4}) but same issue as described above, it will only work fine if I do boss_db:find(post, [], [{limit,1})


Thanks!
Reply all
Reply to author
Forward
0 new messages