gpt-3.5-turbo-0613· OpenAI
WildChat-4.8M (AI2)
const userId = ctx.state.user.id; const decks = await…
- User
const userId = ctx.state.user.id; const decks = await strapi.query('api::deck.deck').findMany({ where: { owner: userId }, populate: ['cards', 'cards.card'], // 使用 populate 方法获取关联的卡片对象 })。我想改为查找 owner。不等于null的 deck。怎么修改?
- Assistant
你可以使用Sequelize的"not"操作符来完成这个操作。以下是修改后的代码示例:
const userId = ctx.state.user.id; const decks = await strapi.query('api::deck.deck').findMany({ where: { owner: userId, owner_not: null }, populate: ['cards', 'cards.card'], });在这个示例中,我们添加了一个
owner_not: null条件,它将返回owner不等于null的deck对象。