caminte
caminte copied to clipboard
Cannot read property 'create' of undefined
I've tried many methods to access a model, in each case create
is not a function.
import caminte from 'caminte'
const User = caminte.model('User')
import caminte from 'caminte'
const User = caminte.schema.models.User
import User from '../models/UserModel'
import { User } from '../models'
import models from '../models'
const { User } = models
All to no avail. I used caminte-cli
to create the models.
module.exports = function (schema) {
const User = schema.define('user', {
name : { type : schema.String },
email : { type : schema.String },
password : { type : schema.String },
created : { type : schema.Date }
});
return User;
}
My server looks like this.
import Express from 'express'
import routes from './src/routes'
import models from './models'
const app = new Express()
models.init(app)
EDIT: When I use require
inside the middleware function (instead of at the top of the file), I am able to see that caminte.schema.models
contains User
. However, when I import it at the top of the file, it is just {}
, an empty object.