You are not logged in.
Pages: 1
Hello there.
I would like to write the following query exactly.
db.inventory.distinct( "sizes" )
But I couldn't find how to write this in Mormot.
https://docs.mongodb.com/manual/referen … thod-array
I tried the following methods and the like but failed.
Can you help me please.
var DB: TMongoDatabase;
vDocData: TDocVariantData;
begin
DB := MongoCli.Open('core');
DB.RunCommand('getCollection(''inventory'').distinct( "Sizes" )', retVal);
DB.RunCommand('inventory.distinct( "Sizes" )', retVal);
vDocData.InitJSON(VariantToUTF8(DB.Collection['inventory'].FindDoc('distinct( "Sizes" )', [])));
// Server.Retrieve('inventory.distinct( "Sizes" )')
end;
Hello Everyone,
I was trying to search my in memory config data through SearchField, and it returned False whatever i tried first. Then i started debugging into mormot classes and realize, this function never set Result to True.
I am using NightlyBuild and here is original code:
function TSQLRestStorageInMemory.SearchField(const FieldName, FieldValue: RawUTF8; out ResultID: TIDDynArray): boolean;
var n, WhereField: integer;
{$ifndef CPU64}i: integer;{$endif}
Where: TList;
begin
result := false;
if (self=nil) or (fValue.Count=0) then
exit;
if IsRowID(pointer(FieldName)) then
WhereField := SYNTABLESTATEMENTWHEREID else begin
WhereField := fStoredClassRecordProps.Fields.IndexByName(FieldName);
if WhereField<0 then
exit;
inc(WhereField); // FindWhereEqual() expects index = RTTI+1
end;
Where := TList.Create;
try
StorageLock(false,'SearchField');
try
n := FindWhereEqual(WhereField,FieldValue,AddIntegerDynArrayEvent,Where,0,0);
finally
StorageUnLock;
end;
if n=0 then
exit;
SetLength(ResultID,n);
{$ifdef CPU64} // on x64 TList[]=Pointer does map an TID/Int64
{$ifdef FPC}Move{$else}MoveFast{$endif}(Where.List[0],ResultID[0],n*SizeOf(TID));
{$else}
with Where do
for i := 0 to Count-1 do
ResultID[i] := PPtrIntArray(List)^[i];
{$endif}
finally
Where.Free;
end;
end;
It returns False but still fill ResultID array. I fixed my code but i thought you should know this problem.
Best regards
When I compile my code I get more than 700+ of this warning. I want to clean them all up.
Is casting the only way? like RawUTF8(aStringValue) or String(aRawUTF8Value)
Is there any other way to suggest? Helper vs.
Pages: 1