Cmdlets for MongoDB

Build 24.0.9062

WriteScheme Parameter (Connect-MongoDB Cmdlet)

Sets whether the object type for inserted or updated objects is determined from the existing column metadata or the input value type.

Syntax

Connect-MongoDB -WriteScheme string

Possible Values

RawValue, Metadata

Data Type

cstr

Default Value

"Metadata"

Remarks

Sets whether the object type for inserted or updated objects is determined from the existing column metadata or the input value type. When the default value Metadata is used, the 本製品 uses the data type as determined by the TypeDetectionScheme for objects pushed to MongoDB. When the value is set to RawValue, the type of the object in the INSERT determines what type is used for MongoDB.

For example, if you have a field 'c1' in MongoDB defined as String type, the metadata returns the column as String as well. In the following query, the resulting field in MongoDB is therefore defined as String when using WriteScheme=Metadata. But when using RawValue, the inserting field type is Date instead since the FROM_UNIXTIME() function returns an actual Date object:

INSERT INTO Table1 (c1) VALUES (FROM_UNIXTIME(1636910867039, 0))

Inserting an empty array

With WriteScheme=RawValue, use the following syntax to insert an empty BSON array:
INSERT INTO t1 ("c1") VALUES (())

This returns an empty array:

"c1":[]

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9062