以下为schama
{
"bsonType": "object",
"permission": {
"create": "'album_course_manage' in auth.permission",
"delete": "'album_course_manage' in auth.permission",
"read": true,
"update": "'album_course_manage' in auth.permission"
},
"required": [
"name",
"media_file",
"album_ids"
],
"properties": {
"_id": {
"description": "存储文档 ID(商品 ID),系统自动生成"
},
"name": {
"bsonType": "string",
"description": "课程名称",
"title": "课程名称",
"trim": "both"
},
"desc": {
"bsonType": "string",
"description": "课程描述",
"title": "课程描述",
"trim": "both"
},
"course_length": {
"bsonType": "string",
"description": "课程时长",
"title": "课程时长",
"trim": "both"
},
"course_length_seconds": {
"bsonType": "int",
"description": "课程时长-秒",
"title": "课程时长-秒",
"defaultValue": 0
},
"play_times": {
"bsonType": "int",
"description": "播放次数",
"title": "播放次数",
"defaultValue": 0
},
"album_ids": {
"bsonType": "array",
"description": "所属专辑id列表",
"title": "所属专辑",
"foreignKey": "lz-album._id",
"enum": {
"collection": "lz-album",
"field": "_id as value, name as text"
}
},
"media_file": {
"bsonType": "file",
"description": "课程文件",
"title": "课程文件",
"permission": {
"read": "'appGetCourse' in action || 'album_course_manage' in auth.permission"
}
},
"video_file": {
"bsonType": "file",
"description": "课程视频文件",
"title": "课程视频文件",
"permission": {
"read": "'appGetCourse' in action || 'album_course_manage' in auth.permission"
}
},
"add_date": {
"bsonType": "timestamp",
"defaultValue": {
"$env": "now"
},
"description": "上架时间"
},
"enable": {
"bsonType": "bool",
"description": "是否上架销售",
"title": "启用",
"defaultValue": false
},
"free": {
"bsonType": "bool",
"description": "是否为免费试听",
"title": "免费试听",
"defaultValue": false
},
"order": {
"bsonType": "int",
"title": "显示排序",
"description": "排序",
"defaultValue": 0
}
}
}
云数据库有这样一条记录,这条数据初始添加的时候,其中video_file为可选,初始设置为null
{
"add_date": 1639536264900,
"album_ids": [
"859059a56197ae9a06da8c1d06cbc14d"
],
"course_length": "00:00",
"course_length_seconds": 0,
"enable": true,
"free": false,
"media_file": {
"extname": "mp3",
"fileID": "cloud://tcb-qityvfnccrppizja0c5a4-594724.7463-tcb-qityvfnccrppizja0c5a4-594724-1308150812/1639536261289_0.mp3",
"name": "好妹妹 - 不说再见.mp3",
"path": "https://7463-tcb-qityvfnccrppizja0c5a4-594724-1308150812.tcb.qcloud.la/1639536261289_0.mp3",
"size": 11967457,
"url": "https://7463-tcb-qityvfnccrppizja0c5a4-594724-1308150812.tcb.qcloud.la/1639536261289_0.mp3"
},
"name": "好妹妹 - 不说再见",
"order": 2,
"play_times": 0,
"video_file": null
}
在前端调用update更新这条数据的时候,video_file字段通过file_picker选择了一个文件上传更新的时候,会报错导致这个字段无法更新
以下为提交的更新对象
{"name":"好妹妹 - 不说再见","media_file":{"extname":"mp3","name":"好妹妹 - 不说再见.mp3","path":"https://7463-tcb-qityvfnccrppizja0c5a4-594724-1308150812.tcb.qcloud.la/1639536261289_0.mp3","size":11967457,"fileID":"cloud://tcb-qityvfnccrppizja0c5a4-594724.7463-tcb-qityvfnccrppizja0c5a4-594724-1308150812/1639536261289_0.mp3","url":"https://7463-tcb-qityvfnccrppizja0c5a4-594724-1308150812.tcb.qcloud.la/1639536261289_0.mp3"},"video_file":{"extname":"mp4","fileType":"video","name":"2.mp4","path":"https://7463-tcb-qityvfnccrppizja0c5a4-594724-1308150812.tcb.qcloud.la/1639537441518_0.mp4","size":8417062,"fileID":"cloud://tcb-qityvfnccrppizja0c5a4-594724.7463-tcb-qityvfnccrppizja0c5a4-594724-1308150812/1639537441518_0.mp4","url":"https://7463-tcb-qityvfnccrppizja0c5a4-594724-1308150812.tcb.qcloud.la/1639537441518_0.mp4"},"enable":true,"order":2,"course_length":"00:00","course_length_seconds":0,"play_times":0,"free":false,"album_ids":["859059a56197ae9a06da8c1d06cbc14d"]}
以下为报错信息
errCode: DATABASE_REQUEST_FAILED | errMsg: [FailedOperation] multiple write errors: [{write errors: [{Cannot create field 'extname' in element {video_file: null}}]}, {<nil>}]
liu666
2023.4.13问题还存在
2023-04-13 11:33
DCloud_uniCloud_WYQ
你怎么用的?上面说的调整试jql对bsonType: file类型字段做的处理。如果你没有使用jql注意自己对复杂类型过滤null值
2023-04-13 16:48