-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Typed "where" queries in Local API #9685
-
Hi, I want to make local api calls partly reusable in a function. To make this work properly I want to type "Where". How can I achieve this?
import {BasePayload, Where} from 'payload';
export const countUsers = async (where: Where, payload: BasePayload): Promise<number> =>
payload
.count({
collection: 'users',
where,
})
.then((result) => result.totalDocs);
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments
-
Unfortunately, the where property is not strongly typed. You can use import { Where } from 'payload', as you have in your code snippet but that will only add the "and" and "or" properties. I guess this requires improvement.
Beta Was this translation helpful? Give feedback.
All reactions
-
I've just started using Payload, coming across from Keystone. Really happy and impressed with it so far but quite surprised to run into this issue where there is no typing on where. Hoping this feature gets incorporated soon 🙏🏼
Beta Was this translation helpful? Give feedback.