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

user defined ObjectId with keystone.createItems gets overwritten with new _id #4956

Open
Joel-Mckay opened this issue Aug 14, 2019 · 0 comments

Comments

@Joel-Mckay
Copy link

Joel-Mckay commented Aug 14, 2019

Expected behavior
_id can be user defined for data/index restore operations

Actual/Current behavior
ignores old _id and generates new _id every time
(I am new to the api, so there may be a reason for this I haven't read about yet)

Steps to reproduce the actual/current behavior

 var keystone = require('keystone');
 var Types = keystone.Field.Types;
 const errors = require("errors");
 // ...
 //json object based on default User Model entry
 var backupAcc = JSON.parse('{"_id":"5d3f62bca9108026a732c9fa","logins":0,"password":"newTest","email":"[email protected]","__v":0,"isAdmin":false,"name":{"last":"Sad","first":"Panda"}}');
 //
 // backupAcc['_id']='ObjectId("'+ backupAcc['_id']+'")';
 backupAcc['_id']= keystone.mongoose.Types.ObjectId( backupAcc['_id']);
 //
 var payload ={};
	 payload['User'] = Array();
	 payload['User'][0] = backupAcc;
 //
 keystone.createItems(payload, { verbose: true}, function (err, stats) { 
	 //wrong '_id' generated upon insert, delete, and insert again

Environment
Keystone 4
Node.js v12.6.0

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

1 participant