generator-es6-graphql
generator-es6-graphql copied to clipboard
npm start error
.get(function () { ^ TypeError: UserSchema.virtual(...).get is not a function
This does happen after a fresh run of the generator?
node 6.0.0 yo then npm install npm start
I went through the same error. Googled it and apparently it happens because the User schema defines a property createdAt
AND a virtual property createdAt
, and that's not supported.
#src/models/Users.js:5
const UserSchema = new Schema({
username: { type: String, required: true, index: { unique: true } },
password: { type: String, required: true },
createdAt: { type: Date },
updatedAt: { type: Date },
mail: { type: String }
});
UserSchema
.virtual('createdAt')
.get(function () {
return this._id.getTimestamp();
});
I deleted the virtual declaration and it worked.
Maybe that feature was supported in a previous version of Mongoose?
Got the same error here, fresh installation too.