FireDAC.Phys.MongoDBWrapper.TMongoDocument.Add

Aus RAD Studio API Documentation
Wechseln zu: Navigation, Suche

Delphi

function Add(const AKey: String; const AValue: String): TMongoDocument; overload;
function Add(const AKey: String; const AValue: Int32): TMongoDocument; overload;
function Add(const AKey: String; const AValue: Int64): TMongoDocument; overload;
function Add(const AKey: String; const AValue: Extended): TMongoDocument; overload;
function Add(const AKey: String; const AValue: Boolean): TMongoDocument; overload;
function Add(const AKey: String; const AValue: TDateTime): TMongoDocument; overload;
function Add(const AKey: String; const AValue: TBytes;  ABinaryType: TJsonBinaryType = TJsonBinaryType.Generic): TMongoDocument; overload;
function Add(const AKey: String; const AValue: TMongoOID): TMongoDocument; overload;
function Add(const AKey: String; const AValue: TJsonOid): TMongoDocument; overload;
function Add(const AKey: string; const AValue: TJsonRegEx): TMongoDocument; overload;
function Add(const AKey: string; const AValue: TJsonDBRef): TMongoDocument; overload;
function Add(const AKey: string; const AValue: TJsonCodeWScope): TMongoDocument; overload;
function Add(const AKey: String; const AValue: TVarRec): TMongoDocument; overload;
function Add(const AKey: String; const AValues: array of const): TMongoDocument; overload;
function Add(const AKey: String; const AValue: Variant): TMongoDocument; overload;

C++

TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const System::UnicodeString AValue)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const int AValue)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const __int64 AValue)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const System::Extended AValue)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const bool AValue)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const System::TDateTime AValue)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const System::DynamicArray<System::Byte> AValue, System::Json::Types::TJsonBinaryType ABinaryType = (System::Json::Types::TJsonBinaryType)(0x0))/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, TMongoOID* const AValue)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const System::Json::Types::TJsonOid &AValue)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const System::Json::Types::TJsonRegEx &AValue)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const System::Json::Types::TJsonDBRef &AValue)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const System::Json::Types::TJsonCodeWScope &AValue)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const System::TVarRec &AValue)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const System::TVarRec *AValues, const int AValues_High)/* overload */;
TMongoDocument* __fastcall Add(const System::UnicodeString AKey, const System::Variant &AValue)/* overload */;

Eigenschaften

Typ Sichtbarkeit Quelle Unit Übergeordnet
function public
FireDAC.Phys.MongoDBWrapper.pas
FireDAC.Phys.MongoDBWrapper.hpp
FireDAC.Phys.MongoDBWrapper TMongoDocument


Beschreibung

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit einem bestimmten Typ hinzu und gibt eine Referenz auf dieses Objekt zurück.

Mit dieser Methode fügen Sie einem MongoDB-Dokument ein neues Schlüssel/Wertepaar oder ein Array-Element hinzu.

Diese Methode ist überladen. Verwenden Sie die geeignete überladene Methode, um ein Schlüssel/Wertepaar oder ein Array-Element mit einem bestimmten Typ hinzuzufügen.

Methoden-Header Beschreibung
 Add(const AKey: String; const AValue: String)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ String hinzu.

Add(const AKey: String; const AValue: Int32)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ Int32 hinzu.

Add(const AKey: String; const AValue: Int64)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ Int64 hinzu.

Add(const AKey: String; const AValue: Extended)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ Extended hinzu.

Add(const AKey: String; const AValue: Boolean)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ Boolean hinzu.

Add(const AKey: String; const AValue: TDateTime)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ TDateTime hinzu.

Add(const AKey: String; const AValue: TBytes;
      ABinaryType: TJsonBinaryType = TJsonBinaryType.Generic)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ TBytes hinzu. Optional können Sie den Parameter ABinaryType angeben, der den binären BSON-Untertypen entspricht.

Add(const AKey: String; const AValue: TMongoOID)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ TMongoOID hinzu.

Add(const AKey: String; const AValue: TJsonOid)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ TJsonOid hinzu.

Add(const AKey: String; const AValue: TJsonRegEx)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ TJsonRegEx hinzu.

Add(const AKey: String; const AValue: TJsonDBRef)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ TJsonDBRef hinzu.

Add(const AKey: String; const AValue: TJsonCodeWScope)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ TJsonCodeWScope hinzu.

Add(const AKey: String; const AValue: TVarRec)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit dem Typ TVarRec hinzu.

Add(const AKey: String; const AValues: array of const)

Fügt ein verschachteltes Array unter Verwendung des offenen Arrays AValues als Array-Elemente hinzu.

Das offene Array repräsentiert "analysiertes" JSON. Führen Sie Folgendes aus, um Elemente hinzuzufügen:

  • Um ein Schlüssel/Wertepaar hinzuzufügen, geben Sie den Schlüsselnamen gefolgt von einem Wert an.
  • Um ein Array-Element hinzuzufügen, geben Sie einfach einen Wert an.
  • Um ein verschachteltes Objekt hinzuzufügen, müssen dessen Schlüssel/Wertepaare in "{" und "}" eingeschlossen sein.
  • Um ein verschachteltes Array hinzuzufügen, müssen dessen Elemente in "[" und "]" eingeschlossen sein.

Zum Beispiel:

    • Add('coords', [123.45, 80.90]) -> "coords": [123.45, 80.90]
    • Add('grades', ['{', 'grade', 'A', 'score', 11, '}', '{', 'grade', 'B', 'score', 17, '}']) -> "grades": [{"grade": "A", "score": 11}, {"grade": "B", "score": 17}]
Add(const AKey: String; const AValue: Variant)

Fügt ein Schlüssel/Wertepaar oder ein Array-Element mit einem durch den Datentyp Variant repräsentierten Typ hinzu.

HINWEIS: Beim Hinzufügen eines Arrays wird der AKey-Wert ignoriert. Aus Gründen der besseren Lesbarkeit können Sie einen Array-Index angeben.

Beispiele

Sehen Sie sich zur Klärung die folgenden Beispiele an:

Delphi:
var
  oDoc: TMongoDocument;
....
  oDoc := FEnv.NewDoc;
  oDoc
    .BeginObject('address')
      .Add('street', '2 Avenue')
      .Add('zipcode', '10075')
      .Add('building', '1480')
      .BeginArray('coord')
        .Add('0', -73.9557413)
        .Add('1', 40.7720266)
      .EndArray
    .EndObject
    .Add('borough', 'Manhattan')
    .Add('cuisine', 'Italian');
C++Builder:
....
  TMongoDocument *oDoc = FEnv->NewDoc();
  oDoc
    ->BeginObject("address")
      ->Add("street", System::UnicodeString("2 Avenue"))
      ->Add("zipcode", System::UnicodeString("10075"))
      ->Add("building", System::UnicodeString("1480"))
      ->BeginArray("coord")
        ->Add("0", -73.9557413)
        ->Add("1", 40.7720266)
      ->EndArray()
    ->EndObject()
    ->Add("borough", System::UnicodeString("Manhattan"))
    ->Add("cuisine", System::UnicodeString("Italian"));

Siehe auch