Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
37 lines
859 B
Plaintext
37 lines
859 B
Plaintext
import { preferencesCollectionSlug } from '../config.js';
|
|
export async function findOne(args) {
|
|
const { key, req: { payload }, req, user } = args;
|
|
if (!user) {
|
|
return null;
|
|
}
|
|
const where = {
|
|
and: [
|
|
{
|
|
key: {
|
|
equals: key
|
|
}
|
|
},
|
|
{
|
|
'user.value': {
|
|
equals: user.id
|
|
}
|
|
},
|
|
{
|
|
'user.relationTo': {
|
|
equals: user.collection
|
|
}
|
|
}
|
|
]
|
|
};
|
|
const { docs } = await payload.db.find({
|
|
collection: preferencesCollectionSlug,
|
|
limit: 1,
|
|
pagination: false,
|
|
req,
|
|
sort: '-updatedAt',
|
|
where
|
|
});
|
|
return docs?.[0] || null;
|
|
}
|
|
|
|
//# sourceMappingURL=findOne.js.map |