云函数查询语句,在云开发后台测试没有问题,但在小程序端总是报错,是什么原因?示例如下
以下云函数查询语句,在云开发后台测试没有问题,但在小程序端总是报错,是什么原因?db.collection('stitem').aggregate() .lookup({ from: 'article', localField: 'article_id', foreignField: '_id', as: 'article', }).replaceRoot({ newRoot: $.mergeObjects([ $.arrayElemAt(['$article', 0]), '$$ROOT' ]) }).project({ article: 0 }) .end() 小程序端报错如下: Error: cloud.callFunction:fail Error: errCode: -504002 functions execute fail | errMsg: ReferenceError: $ is not defined at get_st_detail (/var/user/index.js:71:14) at Runtime.exports.main [as handler] (/var/user/index.js:15:14) at Runtime.handleOnce (/var/runtime/node16/Runtime.engine.js:135:21) at Timeout._onTimeout (/var/runtime/node16/Runtime.engine.js:54:12) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7) (callId: 1714035431672-0.21178932569511377) (trace: 16:57:11 start->16:57:12 system error (Error: errCode: -504002 functions execute fail | errMsg: ReferenceError: $ is not defined at get_st_detail (/var/user/index.js:71:14) at Runtime.exports.main [as handler] (/var/user/index.js:15:14) at Runtime.handleOnce (/var/runtime/node16/Runtime.engine.js:135:21) at Timeout._onTimeout (/var/runtime/node16/Runtime.engine.js:54:12) at listOnTimeout (node:internal/timers:557:17) at processTimers (node:internal/timers:500:7)), abort) at R (<anonymous>:1:245532) at <anonymous>:1:279958(env: macOS,mp,1.06.2402040; lib: 3.4.3)