.field('book_id{title as book_title,author as book_author},quantity as order_quantity')// 这里联表查询book表返回book表内的title、book表内的author、order表内的quantity,并将title重命名为book_title,author重命名为book_author,quantity重命名为order_quantity
.field('book_id{title as book_title,author as book_author},quantity as order_quantity')// 这里联表查询book表返回book表内的title、book表内的author、order表内的quantity,并将title重命名为book_title,author重命名为book_author,quantity重命名为order_quantity
...
@@ -1529,7 +1541,8 @@ db.collection('order,book')
...
@@ -1529,7 +1541,8 @@ db.collection('order,book')
副表字段使用别名需要注意,如果写成`.field('book_id.title as book_id.book_title,book_id.author,quantity as order_quantity')` book_title将会是由book_id下每一项的title组成的数组,这点和mongoDB内数组表现一致
副表字段使用别名需要注意,如果写成`.field('book_id.title as book_id.book_title,book_id.author,quantity as order_quantity')` book_title将会是由book_id下每一项的title组成的数组,这点和mongoDB内数组表现一致
.field('book_id.title as book_title,book_id.author as book_author,quantity as order_quantity')// book_id.title、book_id.author为副表字段,使用别名时效果和上一个示例不同,请见下方说明
.field('book_id.title as book_title,book_id.author as book_author,quantity as order_quantity')// book_id.title、book_id.author为副表字段,使用别名时效果和上一个示例不同,请见下方说明