So, I've git a large production database dump with _id
field as strings
. Different collections got those string's length different. There're a lot of relations there. I need a way to change string _ids
to ObjectId
ones.
What I've tried already:
1) Looking mongoose/mongodb documentation for single command to do that failed
2) node.js migration script that grabs all the entries in one collection and wraps string
id into ObjectId
just fails either because of stack overflow FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
if we're trying to delete-and-recreate approach or with an error about bad string lenght and impossibility to create ObjectId
from that string.
Will attach data samples and/or mongoose schema a bit later.