[erlang-questions] Why is this delete_object giving me an error?
ryeguy
ryeguy1@REDACTED
Mon Mar 16 15:18:00 CET 2009
Oh, so is there no way to directly delete an object using a secondary
index? ID would be my primary index, so I would have to either :
A) Get the ID and delete by that with delete() or
B) Get the whole record and delete by that with delete_object()?
Do I understand this correctly?
On Mar 16, 9:21 am, Jeroen Koops <koop...@REDACTED> wrote:
> Hi,
>
> dirty_delete_object (and also delete_object) can only be used with a
> complete record - i.e. all fields must be filled in. It does not accept
> wildcard patterns.
>
> If you want to delete all user with a certain first name, you need an index
> on the first_name attribute, query for all users with that first name using
> mnesia:index_read or dirty_index_read, and finally manually delete all
> returned records with delete_object or delete.
>
> Regards,
>
> Jeroen
>
> On Mon, Mar 16, 2009 at 2:05 PM, ryeguy <ryeg...@REDACTED> wrote:
> > I don't see what's wrong here, but I may just misunderstand the
> > syntax. I'm trying to delete a "user" record from my "user" mnesia
> > table who have the first name of "ryan" (there are multiples of them).
> > Here is what I do:
>
> > Delete=#user{first_name = "ryan", _ = '_'},
> > mnesia:dirty_delete_object(Delete)
>
> > Here is my record definition:
> > -record(user, {id,
> > username,
> > password,
> > email,
> > first_name,
> > last_name,
> > last_login, % Date/time user last logged in
> > reg_date}). % Date/time user registered the
> > account
>
> > And here is the exception I'm getting:
> > ** exception exit: {aborted,
> > {bad_type,user,
> > {user,'_','_','_','_',"ryan",'_','_','_'}}}
> > in function mnesia:abort/1
> > in call from users:register/1
>
> > It seems like a perfect match. What could cause this problem?
>
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questi...@REDACTED
> >http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questi...@REDACTED://www.erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list