0

我有一个搜索工作表的工作模型。该表是使用 rails 创建的,我在 Job 模型中将“migrate”设置为“safe”。我已经写出了模型中的所有属性。我无法在sails 控制台中获得基本功能。我在表中有三个作业,ID 为 1、2 和 3。当我执行时:

sails> Job.findOneById(1).done(function(err,job){console.log(j.id)})

它在我身上大便。帆控制台崩溃(超级烦人)。输出如下所示:

sails> Job.findOneById(1).done(function(err,job){console.log(j.id)})
undefined
sails> 
/home/redmage/tac/node_modules/sails-postgresql/lib/query.js:544
    var type = self._schema[key].type;
                                ^
TypeError: Cannot read property 'type' of undefined
    at /home/redmage/tac/node_modules/sails-postgresql/lib/query.js:544:33
    at Array.forEach (native)
    at Query.cast (/home/redmage/tac/node_modules/sails-postgresql/lib/query.js:541:23)
    at /home/redmage/tac/node_modules/sails-postgresql/lib/adapter.js:372:32
    at Array.forEach (native)
    at __FIND__ (/home/redmage/tac/node_modules/sails-postgresql/lib/adapter.js:371:23)
    at Query.handleReadyForQuery (/home/redmage/tac/node_modules/sails-postgresql/node_modules/pg/lib/query.js:84:10)
    at null.<anonymous> (/home/redmage/tac/node_modules/sails-postgresql/node_modules/pg/lib/client.js:159:19)
    at EventEmitter.emit (events.js:117:20)
    at null.<anonymous> (/home/redmage/tac/node_modules/sails-postgresql/node_modules/pg/lib/connection.js:97:12)
    at Socket.EventEmitter.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:746:14)
    at Socket.EventEmitter.emit (events.js:92:17)
    at emitReadable_ (_stream_readable.js:408:10)
    at emitReadable (_stream_readable.js:404:5)
    at readableAddChunk (_stream_readable.js:165:9)
    at Socket.Readable.push (_stream_readable.js:127:10)
    at TCP.onread (net.js:528:21)

这是 Job 的 ORM。这是非常基本的:

module.exports = {

  //VERY IMPORTANT:
  migrate: 'safe', 

  tableName: 'jobs',

  attributes: {

  }
}
4

0 回答 0