// 云函数入口文件 const cloud = require('wx-server-sdk') cloud.init() const db = cloud.database() // 云函数入口函数 exports.main = async (event, context) => { const { OPENID } = cloud.getWXContext() const notifications = await db.collection('notification') .aggregate() .match({ user_id: OPENID }) .skip(event.page_token) .limit(event.page_size) .lookup({ from: 'message', localField: 'msg_id', foreignField: '_id', as: 'message' }) .unwind('$message') .lookup({ from: 'publisher', localField: 'message.pub_id', foreignField: '_id', as: 'message.publisher' }) .unwind('$message.publisher') .end() return { list: notifications.list, next_page_token: event.page_token + notifications.list.length, status: 'OK' } }