Questions tagged [mongoose-models]

Mongoose Models are constructors compiled from Schema definitions. They are responsible to creating and editing documents from MongoDB.

50 questions
0
votes
2 answers

Creating mongoose schema that contains array of Objects

How do I create a mongoose schema that has the following structure { data: { name: "John doe", attributes: [ { text: "Sample text", created_at: "2018-08-23" }, { …
Dave Kalu
  • 1,520
  • 3
  • 19
  • 38
0
votes
0 answers

Receiving 'TypeError: User is not a constructor' error when exporting Mongoose model

I know this error has already been asked and answered here multiple times, but after sifting through all the previously mentioned fixes I still cannot figure out the error in my code. models/index.js require('./users'); models/users.js const…
0
votes
1 answer

Mongoose : Types referring to other models

I've this: models/record.js var mongoose = require("mongoose"); var RecordSchema = new mongoose.Schema({ address : require("./address").Address }); var Record = mongoose.model('Record', RecordSchema); module.exports = { Record:…
Marco Jr
  • 6,496
  • 11
  • 47
  • 86
0
votes
1 answer

Using mongoose.model without schema param

I'm working through this Node ToDoList App API tutorial. It has one model, one controller and one routes…
David Kennell
  • 1,147
  • 2
  • 11
  • 22
-1
votes
2 answers

Cannot return method using module exports

I am trying to make a database file that delivers connection, model etc for mongoose (MongoDb). So when I return the Mongoose Model, the create method becomes "undefined". database.js //model connection exports.MongoModel = async function…
1 2 3
4