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

First param to schema.plugin() must be a function, got "object" #7

Open
geetikaTiwari007 opened this issue Apr 22, 2019 · 2 comments
Open

Comments

@geetikaTiwari007
Copy link

I tried your code but getting this error as mongoose.plugin needs function as first param but we are passing object.
Please guide how to resolve the same.

@lykmapipo
Copy link
Owner

@geetikaTiwari007

Try follow:

const mongoose = require('mongoose');
const faker = require('mongoose-faker');

const UserSchema = new mongoose.Schema({
 name: { type: String, fake: f => f.name.findName() }
});
UserSchema.plugin(faker);

const User = mongoose.model('User', UserSchema);
const user = User.fake();
// => {_id: ..., name: ...}

@maheraldous
Copy link

maheraldous commented Nov 23, 2020

@lykmapipo It not working.

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

3 participants