Skip to content

Using factory with Mongo.ObjectID collections #25

@ghost

Description

My collections use Mongo.ObjectID's for _id generation.
export const Clients = new Mongo.Collection('clients', { idGeneration: 'MONGO' });

However, factory seems to default to a Random.Id() id generation which fails a lot of tests for me, so I tried adding id generation right into factory definition:
Factory.define('client', Clients, { _id: new Mongo.ObjectID(), //... });

This results in a mongo duplicate id error when I call Factory.create('client') three times in a row, though. For some reason all three clients end up with the same _id field.

Please advise.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions