@@ -94,7 +94,7 @@ TUgarCollection = class(TInterfacedObject, IUgarCollection)
9494 function _GetName : String;
9595
9696 function InsertOne (const ADocument: TUgarBsonDocument): Boolean; overload;
97- function InsertOne (const ADocument: TJsonObject): Boolean ; overload;
97+ function InsertOne (const ADocument: TJsonObject): TJSONObject ; overload;
9898 function InsertOne (const ADocument: string): Boolean; overload;
9999
100100 function InsertMany (const ADocuments: array of TUgarBsonDocument; const AOrdered: Boolean = True): Integer; overload;
@@ -120,7 +120,7 @@ TUgarCollection = class(TInterfacedObject, IUgarCollection)
120120 function Find (const AFilter: TUgarFilter; const AProjection: TUgarProjection): IUgarCursor; overload;
121121 function Find (const AFilter: TUgarFilter): IUgarCursor; overload;
122122 function Find (const AProjection: TUgarProjection): IUgarCursor; overload;
123- function Find : IUgarCursor ; overload;
123+ function Find : TJSONArray ; overload;
124124 function Find (const AFilter: TUgarFilter; const ASort: TUgarSort): IUgarCursor; overload;
125125 function Find (const AFilter: TUgarFilter; const AProjection: TUgarProjection; const ASort: TUgarSort)
126126 : IUgarCursor; overload;
@@ -354,9 +354,19 @@ function TUgarCollection.Find(const AFilter, AProjection: TBytes): IUgarCursor;
354354 Result := TUgarCursor.Create(FProtocol, FFullName, Reply.Documents, Reply.CursorId);
355355end ;
356356
357- function TUgarCollection.Find : IUgarCursor;
357+ function TUgarCollection.Find : TJSONArray;
358+ var
359+ LBSON: TEnumerator<TUgarBsonDocument>;
358360begin
359- Result := Find(nil , nil );
361+ Result := TJSONArray.Create;
362+
363+ LBSON := Find(nil , nil ).GetEnumerator;
364+
365+ while LBSON.MoveNext do
366+ begin
367+ Result.AddElement(TJSONObject.ParseJSONValue(LBSON.Current.ToJson));
368+ end ;
369+
360370end ;
361371
362372function TUgarCollection.FindOne (const AFilter, AProjection: TBytes): TUgarBsonDocument;
@@ -466,9 +476,10 @@ function TUgarCollection.InsertOne(const ADocument: TUgarBsonDocument): Boolean;
466476 Result := (HandleCommandReply(Reply) = 1 );
467477end ;
468478
469- function TUgarCollection.InsertOne (const ADocument: TJsonObject): Boolean ;
479+ function TUgarCollection.InsertOne (const ADocument: TJsonObject): TJSONObject ;
470480begin
471- Result := InsertOne(TUgarBsonDocument.Parse(ADocument.ToJSON));
481+ InsertOne(TUgarBsonDocument.Parse(ADocument.ToJSON));
482+ Result := ADocument;
472483end ;
473484
474485function TUgarCollection.InsertMany (const ADocuments: TArray<TJsonObject>; const AOrdered: Boolean): Integer;
@@ -656,8 +667,10 @@ function TUgarCursor.TEnumerator.DoMoveNext: Boolean;
656667 if Result then
657668 Inc(FIndex)
658669 else if (FCursorId <> 0 ) then
670+ begin
659671 GetMore;
660- Result := (FPage <> nil );
672+ Result := (FPage <> nil );
673+ end ;
661674end ;
662675
663676procedure TUgarCursor.TEnumerator .GetMore;
0 commit comments