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

discriminatorKey on insert? #44

Open
seanlee10 opened this issue Apr 24, 2016 · 0 comments
Open

discriminatorKey on insert? #44

seanlee10 opened this issue Apr 24, 2016 · 0 comments

Comments

@seanlee10
Copy link

seanlee10 commented Apr 24, 2016

var ItemSchema = new Schema({
    id: Number,
    created: { type: Date, default: Date.now }
}, { collection : 'items', discriminatorKey : '_type' });

This is my parent schema, and it is extended by 2 child schemas Car and Truck.

Car.collection.insert([{'photo':'/civic.jpg'},{'photo':'/accord.jpg'}], function (err) {})
Truck.collection.insert([{'photo':'/sierra.jpg'},{'photo':'/titan.jpg'}], function (err) {})

But unlike your example, I used insert as I wanted create records in bulk.

and after the insertion, I don't see '_type' field populated in the items collection.

So I was wondering if the 'discriminatorKey' only works for save() and not for insert().

Could you share some insight on this matter? Thanks!

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