如何注入用户字段
#257
Replies: 2 comments 2 replies
-
如果可以你最好贴一下你的部分代码 |
Beta Was this translation helpful? Give feedback.
0 replies
-
mysql 的话要补一段: Database.extend('koishi-plugin-mysql', ({ tables }) => {
tables.user.coins = 'int' // 如果是浮点型就是 float 或者 double 等等
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
User.extend(() => ({ coins: 114514 }))
参数类型 function(): {coins: number} 不可分配给参数类型 Getter
类型 function(): {coins: number} 不可分配给类型 (type: T, id: string) => Partial
类型 {coins: number} 不可分配给类型 Partial
看wiki里就是这样写的
用userFields获取字段后
[W] mysql SELECT
flag
,authority
,usage
,id
,name
,onebot
,coins
FROMuser
_user WHEREonebot
= '112222' +5s[W] session userinfo
ER_BAD_FIELD_ERROR: Unknown column 'coins' in 'field list' at MysqlDatabase.query (E:\桌面\杂物\ProjectE\koishi\node_modules\koishi-plugin-mysql\lib\index.js:15
9:19)
Beta Was this translation helpful? Give feedback.
All reactions