type documentKeys = keyof T; type documentValues = T[keyof T]; type operators = '$eq' | '$ne' | '$gt' | '$gte' | '$lt' | '$lte' | '$regex' | '$options' | '$like' | '$ilike' | '$exists'; type arrayOperators = '$in' | '$nin'; type conditionOperators = '$or' | '$and'; type simpleQuery = { [key in documentKeys]?: documentValues | mixedQuery; }; type mixedQuery = { $exists: boolean; } | { [key in operators]?: documentValues; } | { [key in arrayOperators]?: documentValues[]; }; type conditionalQuery = { [key in conditionOperators]?: Query[]; }; type pushQuery = { $push: simpleQuery; }; type setQuery = { $set: simpleQuery; }; export type Query = simpleQuery | pushQuery | setQuery | conditionalQuery; export {};