generator-es6-graphql icon indicating copy to clipboard operation
generator-es6-graphql copied to clipboard

npm start error

Open gggin opened this issue 8 years ago • 4 comments

.get(function () { ^ TypeError: UserSchema.virtual(...).get is not a function

gggin avatar Jul 11 '16 07:07 gggin

This does happen after a fresh run of the generator?

stylesuxx avatar Jul 15 '16 10:07 stylesuxx

node 6.0.0 yo then npm install npm start

gggin avatar Jul 16 '16 03:07 gggin

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?

d-gubert avatar Jul 30 '16 21:07 d-gubert

Got the same error here, fresh installation too.

CoericK avatar Jul 31 '16 07:07 CoericK