-
Trying to populate postDB collection with user's information from userDB: `mongoose.connect("mongodb://localhost:27017/userDB", { useNewUrlParser: true, useUnifiedTopology: true }); const postDbConnection = mongoose.createConnection('mongodb://localhost:27017/postDB', { useNewUrlParser: true }); const userSchema = new mongoose.Schema({ email: String, const postSchema = new mongoose.Schema({ userSchema.plugin(passportLocalMongoose); // this uses the default connection (to // this uses the second connection (to I get the following error: Cannot access 'User' before initialization Unless I use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Use 'User'. Both ways are correct depending on context, but in this case you can't use |
Beta Was this translation helpful? Give feedback.
Use 'User'. Both ways are correct depending on context, but in this case you can't use
ref: User
becauseUser
isn't defined when you're trying to use it.