Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Providing custom _id for documents #154

Open
AdamPzpn opened this issue Dec 29, 2021 · 4 comments
Open

Providing custom _id for documents #154

AdamPzpn opened this issue Dec 29, 2021 · 4 comments

Comments

@AdamPzpn
Copy link

Trying inserting data into foregin table ends with ignore for _id parameter.

Example:
INSERT INTO warehouse VALUES (uuid_generate_v4()::text, 2, 'Laptop', '2015-11-11T08:13:10Z');

Creates:
"_id" : ObjectId("53720b1904864dc1f5a571a0"),
"warehouse_id" : 2,
"warehouse_name" : "Laptop",
"warehouse_created" : ISODate("2015-11-11T08:13:10Z")

How can I insert literal _id as string into entity?

@jeevanladhe
Copy link

jeevanladhe commented Dec 30, 2021 via email

@AdamPzpn
Copy link
Author

AdamPzpn commented Dec 30, 2021

No problem.

Ad.1

{
"_id" : "1558aeb1-f4fa-4914-82d1-1026d6997976",
"param1" : "fa8118db-c004-442d-92e6-00ed3c50a8cb",
"param2" : "56cfe38d-c3b7-4ef3-a6f4-ca8799a2b14b",
"param3" : "5f6cb622-f8d1-4e08-80ba-0cf3b740641e",
"dateFrom" : "2019-10-27T21:19:48Z",
"dateTo" : null,
"esbSchemaVersion" : 1,
"esbExtIds" : [
{
"sourceName" : "system",
"sourceId" : "456087"
}
],
"esbVersion" : 1
}

AD.2

CREATE FOREIGN TABLE mongodb.collection(
"_id" name NULL COLLATE "C",
"param1" text NULL,
"param2" text NULL,
"param3" text NULL,
"dateFrom" text NULL,
"dateTo" text NULL,
"esbSchemaVersion" int4 NULL,
"esbVersion" int4 NULL,
"esbExtIds" json NULL
)
SERVER mongo_server
OPTIONS (database 'mongoDatabase', collection 'collection');

@vaibhavdalvi93
Copy link

Hi @AdamPzpn ,

Providing custom _id for a document not supported. Currently, mongo_fdw ignores the value of the first column which is the row identifier in MongoDb (_id) and lets MongoDB insert the unique value for that column.

We will do more studies to try to support this feature in near future.

@lukeyang88
Copy link

I saw the last comment was from 1/2022. Is custom _id for a document supported now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants