提交 c53c85f3 编写于 作者: S sw_notepad

【游戏地图-原神】爬虫逻辑修复

上级 6b62606b
...@@ -63,8 +63,34 @@ function kebabCaseObject(originObj) { ...@@ -63,8 +63,34 @@ function kebabCaseObject(originObj) {
return ret return ret
} }
// 转换为数据库接受的数据
function convert4db(originObj) {
if (!_.isObject(originObj)) {
return originObj
}
const ret = {};
for (let key in originObj) {
// 数据库中不定义bool类型的数据,转换为1和0
let val = originObj[key]
if (_.isBoolean(val)) {
val = val ? 1 : 0
}
// 对象转换为字符串
if (_.isObject(val)) {
val = JSON.stringify(val)
}
ret[key] = val
}
return ret
}
export { export {
camelCaseObject, camelCaseObject,
snakeCaseObject, snakeCaseObject,
kebabCaseObject, kebabCaseObject,
convert4db,
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册