#1 Re: mORMot 1 » How to search in collection » 2011-11-22 07:37:43

OK, my idea is like this:
We could search directly using sql query such as:

select a.ID from Customer a where a.Licenses containing 'UserName:"AA"'

I don't know how fast can we search inside the blob. But based on my experience, it will not too fast. But at least it works.
OK, in the mean while, I think I should use One to Many relations first.

Is there anything I can do to help?

#2 mORMot 1 » How to search in collection » 2011-11-22 04:35:08

sachli
Replies: 3

Hi,

I have read the SAD forward and backward but I couldn't find the answer.

I have class like this:

  TLicense = class( TCollectionItem)
  private
    FUserName : TTextProperty;
    FPassword : TTextProperty;
    FActive   : Boolean;
  published
    property UserName : TTextProperty read FUserName write FUserName;
    property Password : TTextProperty read FPassword write FPassword;
    property Active   : Boolean       read FActive   write FActive;
  end;

  TLicenses = class(TCollection)
  public
    property Detail[index:Integer]:TLicense read GetDetail; default;
  end;

  

  TSQLCustomer = class(TSQLStandardRecord)
  private
    ...
    FLicenses   : TLicenses;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property Name:TTextProperty read FName write FName;
     ...
    property Licenses   : TLicenses       read FLicenses      write FLicenses;
  end;

I have already been able to append a record. Now I would like to search all the Customer that have licenses.UserName = 'AA'.

My code is:

  Client.OneFieldValues( TSQLCustomer, 'ID', 'RawUTF8DynArrayContainsCase(UserName,:("AA"):)', Data);
  CheckEquals( 1, Length(Data));

Unfortunately, the Check fails because the query returns nothing.

Is there anything I have done wrong?
What is the right way to search in Collection?


Thanks in advance,

Sachli

Board footer

Powered by FluxBB