问题描述
所以我有以下代码用于knex连接:
const Knex = require('knex');
const User = require('../models/user');
Model.knex(
Knex({
client: 'sqlite3',connection: {
filename: 'src/database.db'
}
},)
);
async function main() {
const users = await User.query();
console.log(users);
}
main();
我的用户模型如下:
module.exports = class User extends Model {
static get tableName() {
return 'users';
}
static get userSchema() {
return {
type: 'object',required: ['id','email','username','discordID'],properties: {
email: { type: 'string' },username: { type: 'string' },id: { type: 'string' },avatar: { type: 'string' },xp: { type: ['number',0] },vipClassic: {
startDate: { type: 'number' },endDate: { type: 'number' },rainbowName: { type: ['boolean',false] },lockedname: { type: ['string','null'] }
}
}
};
}
};
我似乎无法正常工作,并且似乎无法查找/插入数据吗? 最好的方法是什么?检查数据,如果确实存在,则忽略是否创建? 如果我从你们那里得到任何好主意,我将不胜感激
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)