blob: 2f90c9a0d2514545f62838144741e5fc01459cbf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
require('dotenv').config()
const knex = require('knex')({
client: 'mysql2',
// debug: true,
connection: {
host : process.env.DB_HOST,
user : process.env.DB_USER,
password : process.env.DB_PASS,
database : process.env.DB_NAME,
charset : 'utf8',
typecast : function (field, next) {
console.log(field.type)
if (field.type == 'BLOB') {
return field.string()
}
return next()
}
}
})
const bookshelf = require('bookshelf')(knex)
const jsonColumns = require('bookshelf-json-columns')
bookshelf.plugin(jsonColumns)
module.exports = {
bookshelf: bookshelf,
knex: knex,
}
|