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

Deepmerge.all breaks ObjectId #16

Open
itsfrankjames opened this issue Nov 10, 2021 · 0 comments
Open

Deepmerge.all breaks ObjectId #16

itsfrankjames opened this issue Nov 10, 2021 · 0 comments

Comments

@itsfrankjames
Copy link

itsfrankjames commented Nov 10, 2021

I'm using Factoria to generate fixtured for some integration tests.
I'm using MongoDb and sometimes I need knowledge of what an Object's '_id' will be before it's created.
Passing overrides to a Model like in the examples below returns an Object that cannot be written directly to MongoDb because Deepmerge.all clones 'every property from all types of objects'.

`
Factory.define("User", (faker) => ({
_id: new ObjectId(),
firstname: faker.name.firstName(),
lastname: faker.name.lastName(),
email: faker.internet.email(),
timezone: faker.address.timeZone(),
}))

const user_id = new ObjectId();
const user = Factory("User", 1, { _id: user_id });
`

Can we modify the deepmerge.all on line 52 of index.ts to accept options that implements isMergeableObject and only clones properties from non-instantiated objects?

{ isMergeableObject: isPlainObject }

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