[odb-users] An easy one about indexes

Miguel Revilla Rodríguez yo at miguelrevilla.com
Tue Jul 17 06:54:13 EDT 2012

Sure I'll give it a try. I'm developing at full pace right now with
odb and this would be very helpful. This way I can model my whole db
without writing a single SQL statement.

Thanks Boris.

2012/7/17 Boris Kolpackov <boris at codesynthesis.com>:
> Hi Miguel,
> Miguel Revilla Rodríguez <yo at miguelrevilla.com> writes:
>> How do I declare by pragmas additional indexes for a table?
> I've been waiting for this question for a while now ;-). Currently
> there is no way to do it with pragmas. It is always possible to add
> indexes using SQL but, I agree, having a pragma would make this much
> easier. Something along these lines:
> #pragma db object
> struct person
> {
>   #pragma db index     // Add normal index called age_i.
>   unsigned short age_;
>   #pragma db unique
>   std::string email_;  // Add unique index called email_i.
>   std::string first_;
>   std::string last_;
>   // Add composite index called name_i that uses the BTREE method.
>   //
>   #pragma db index("name_i") member(first_) member(last_) method("BTREE")
> };
> I am going to implement this in the next couple of days. Let me know
> if you would like to give it a try.
> Boris

More information about the odb-users mailing list