JDBC Driver for MongoDB

Build 22.0.8462

WriteScheme

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

Possible Values

RawValue, Metadata

Data Type

string

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 driver 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:
INSERTINTO t1 ("c1")VALUES(())

This returns an empty array:

"c1":[]

Copyright (c) 2023 CData Software, Inc. - All rights reserved.
Build 22.0.8462