dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

ORMError: Unknown property type: undefined #759

Closed GitHub-Yann closed 7 years ago

GitHub-Yann commented 7 years ago

Hello, I'm new about node/ node-orm2. Now I encounter such problem. Could you please share me guide about this?

db.js ` var orm = require('orm'); var setting = require("./../public/config/setting.json"); var user = require("./../module/m_user");

var connection = null; function setup(db,cb) { user(orm,db); return cb(null,db); } module.exports = function(cb) { if(connection) return cb(null,connection); orm.connect(setting.dbconfig, function(err, db) { if (err) return cb(err); connection = db; setup(db ,cb); }); };`

m_user.js `module.exports = function(orm,db){

var user = db.define("JS_USER", {

    email:       { mapsTo : 'JS_USER_EMAIL', key: true  },

    password:    {mapsTo: 'JS_USER_PASSWORD',type: 'text'}

});

}`

but when I try to visit my home page, the console shows "ORMError: Unknown property type: undefined" , and it points to the line "db.define"

my package.json { "name": "second", "version": "0.0.0", "private": true, "scripts": { "start": "node ./bin/www" }, "dependencies": { "body-parser": "~1.15.2", "cookie-parser": "~1.4.3", "debug": "~2.2.0", "ejs": "~2.5.2", "express": "~4.14.0", "express-session": "~1.14.2", "log4js": "~1.0.1", "morgan": "~1.7.0", "mysql": "~2.12.0", "orm": "~3.2.0", "serve-favicon": "~2.3.0", "validator": "~6.2.0" } }

dxg commented 7 years ago

What happens if you add a type to email?

email:       { mapsTo : 'JS_USER_EMAIL', key: true, type: 'text'  },
GitHub-Yann commented 7 years ago

@dxg Yes , you are right, I missed the attribute type.