diff --git a/docs/uniCloud/clientdb.md b/docs/uniCloud/clientdb.md index d929295b15725a6107da0b7b7c98956dc34cb0d2..5854d817859aa71c085952bad437c4926b715b16 100644 --- a/docs/uniCloud/clientdb.md +++ b/docs/uniCloud/clientdb.md @@ -797,7 +797,7 @@ db.collection('article,comment') [{ "content": "content1", "article_id": { - "comment": [{ 使用副本foreignKey联查时此处会自动插入一层副表表名 + "comment": [{ // 使用副本foreignKey联查时此处会自动插入一层副表表名 "content": "comment1-1" }, { @@ -805,6 +805,30 @@ db.collection('article,comment') }] } }] + +``` + +副表内的字段也可以使用`as`进行重命名,例如上述查询中如果希望将副表的content重命名为value可以使用如下写法 + +```js +// 重命名副表字段 +db.collection('article,comment') +.where('article_id=="1"') +.field('content,article_id{comment{content as value}}') +.get() + +// 查询结果如下 +[{ + "content": "content1", + "article_id": { + "comment": [{ // 使用副本foreignKey联查时此处会自动插入一层副表表名 + "value": "comment1-1" + }, + { + "value": "comment1-2" + }] + } +}] ``` ### 查询记录过滤,where条件@where