Brian,Kun Liu
Brian,Kun Liu
> > Now, I found a new problem that it cannot connect two tables with `include` when we user `Sequelize.literal` and other functions when using the Orm of Sequelize. >...
在cors里面开启credential熟悉并且设置为true就好了 ` config.cors = { origin:'http://ip:port', credentials: true, allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH' }; `
> https://github.com/shanzemin/mongo-mysql egg-mongoose不支持目录自定义 所以只能自定义egg-sequelize//定义sequelize的配置文件 ```js config.sequelize = { dialect:'mysql',//支持多个sql类的 database:"test", host:"localhost", port:3306, username:"root", password:'root', delegate:'sqlModel',//定义挂载到框架上为ctx.sqlModel baseDir:'sqlModel',//定义model文件目录app/`${sqlModel}` define:{ //定义表时的相关的设置,也可在表中单独定义 //timestamps:false, //是否支持自动生产created_at,updated_at.,deleted_at,自动生成的时间为标准时间 underscored: true, //是否支持驼峰转为表的下划线 freezeTableName:true, //不自动将表名转换为复数形式 //paranoid:false, //删除是否自动插入时间 } } ```
正好看到有邮件通知; 先前也有人提供了相关修改,但是好像因为抛弃了原来的语法特性,所以没有被合并。 我将egg-mongoose进行了修改并保留了原来的语法支持,使得能够支持和自定义目录存放位置和引用方式。并提交到了Pull reuqests里面。 但是,egg-mongoose好像没有人维护了,所以进行了重新发布。 [npm发布地址](https://www.npmjs.com/package/@onewalker/egg-mongoose)
> sequelize有个不爽的地方就是模型建立关联以后,数据库就自动加了主外键。但是不想数据库有主外键 定义的时候 constraints属性设置为false;
> 问题找到了,是因为 健康检查导致的。但另一个问题来了,为什么健康检查时 egg会出现很多 status code 不是 200的情况。有人遇到吗 怎么解决这个问题的呢?
I fixed the problem by edit the Dockerfile as `RUN npm i`. Not the `RUN npm i --registry=https://registry.npm.taobao.org,` The problem is caused by the npm package problem provided by taobao.com,...
> beforeBulkCreate的第一个参数是个数组 > > ```js > hooks: { > beforeBulkCreate: async (users, options) => { > for (const user of users) { > user.createdAt = Date.now() > } > },...
`'use strict'; /** @type Egg.EggPlugin */ module.exports = app => { // the use of your model const { INTEGER,BIGINT,DATE, STRING } = app.Sequelize; const User = app.model.define('users',{ id:{ type:INTEGER,...
明白,也就是beforeBulkCreate和afterBulkCreate不能由hooks挂载到定义的对象.............,那这个函数基本等于没什么用................