gpt4 book ai didi

node.js - Sequelize -cli db :seed returning 'Unhandled rejection TypeError: undefined is not a function'

转载 作者:行者123 更新时间:2023-12-03 22:28:58 25 4
gpt4 key购买 nike

我正在使用 sequelize-cli (v1.9.1) 并且我正在尝试在运行 db:migration 后进行播种,但是当我运行 db:seed 时我不断收到以下错误消息:

Sequelize [Node: 0.12.7, CLI: 1.9.1, ORM: 3.9.0]

Loaded configuration file "src/server/config/config.json".
Using environment "development".
Using gulpfile /usr/local/lib/node_modules/sequelize-cli/lib/gulpfile.js
Starting 'db:seed'...
Finished 'db:seed' after 96 ms
== 20151001101051-admin-user-seed: migrating =======
Unhandled rejection TypeError: undefined is not a function
at Object.SqlString.escape (/Users/me/WebstormProjects/my-project/node_modules/sequelize/lib/sql-string.js:87:15)
at Object.QueryGenerator.escape (/Users/me/WebstormProjects/my-project/node_modules/sequelize/lib/dialects/postgres/query-generator.js:924:22)
at Object.<anonymous> (/Users/me/WebstormProjects/my-project/node_modules/sequelize/lib/dialects/postgres/query-generator.js:356:23)
at Array.map (native)
at Object.<anonymous> (/Users/me/WebstormProjects/my-project/node_modules/sequelize/lib/dialects/postgres/query-generator.js:352:23)
at arrayEach (/Users/me/WebstormProjects/my-project/node_modules/lodash/index.js:1289:13)
at Function.<anonymous> (/Users/me/WebstormProjects/my-project/node_modules/lodash/index.js:3345:13)
at Object.QueryGenerator.bulkInsertQuery (/Users/me/WebstormProjects/my-project/node_modules/sequelize/lib/dialects/postgres/query-generator.js:350:13)
at QueryInterface.bulkInsert (/Users/me/WebstormProjects/my-project/node_modules/sequelize/lib/query-interface.js:576:33)
at Object.module.exports.up (/Users/me/WebstormProjects/my-project/src/server/seeders/20151001101051-admin-user-seed.js:17:31)
at Object.tryCatcher (/usr/local/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/util.js:26:23)
at Object.ret (eval at <anonymous> (/usr/local/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/promisify.js:163:12), <anonymous>:13:39)
at module.exports.redefine.Class._exec (/usr/local/lib/node_modules/sequelize-cli/node_modules/umzug/lib/migration.js:49:23)
at module.exports.redefine.Class.up (/usr/local/lib/node_modules/sequelize-cli/node_modules/umzug/lib/migration.js:33:17)
at null.<anonymous> (/usr/local/lib/node_modules/sequelize-cli/node_modules/umzug/index.js:78:28)
at Object.tapHandler (/usr/local/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/finally.js:63:44)
at Object.tryCatcher (/usr/local/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/util.js:26:23)
at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/promise.js:507:31)
at Promise._settlePromiseAt (/usr/local/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/promise.js:581:18)
at Promise._settlePromises (/usr/local/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/promise.js:697:14)
at Async._drainQueue (/usr/local/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/async.js:123:16)
at Async._drainQueues (/usr/local/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/async.js:133:10)

这是我的种子文件的样子:
'use strict';

module.exports = {
up: function (queryInterface, Sequelize) {

/*
Add altering commands here.
Return a promise to correctly handle asynchronicity.

Example:
return queryInterface.bulkInsert('Person', [{
name: 'John Doe',
isBetaMember: false
}], {});
*/
return queryInterface.bulkInsert('Users', [{
id: Sequelize.UUIDV4,
username: 'someone@email.com',
email: 'someone@email.com'
}], {});
},

down: function (queryInterface, Sequelize) {
/*
Add reverting commands here.
Return a promise to correctly handle asynchronicity.

Example:
return queryInterface.bulkDelete('Person', null, {});
*/
return queryInterface.bulkDelete('Users', null, {});
}
};

最佳答案


sequelize db:seed:all

并分别为每个对象添加 createdDate {createdAt:'2016-03-31T08:00:10.354Z'} 和 updatedDate{updatedAt:'2016-03-31T08:00:10.354Z'} 。

关于node.js - Sequelize -cli db :seed returning 'Unhandled rejection TypeError: undefined is not a function' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32894687/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com