mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 23:07:06 +00:00
[mongodb] nested array/object support for PullOperator (#40056)
This commit is contained in:
committed by
Nathan Shively-Sanders
parent
a5d3d40734
commit
29b43a06a2
Vendored
+3
-1
@@ -1208,7 +1208,7 @@ export type PushOperator<TSchema> = ({
|
||||
};
|
||||
|
||||
export type PullOperator<TSchema> = ({
|
||||
readonly [key in KeysOfAType<TSchema, any[]>]?: Unpacked<TSchema[key]> | QuerySelector<Unpacked<TSchema[key]>>;
|
||||
readonly [key in KeysOfAType<TSchema, any[]>]?: Partial<Unpacked<TSchema[key]>> | ObjectQuerySelector<Unpacked<TSchema[key]>>;
|
||||
} &
|
||||
NotAcceptedFields<TSchema, any[]>) & {
|
||||
readonly [key: string]: QuerySelector<any> | any;
|
||||
@@ -1365,6 +1365,8 @@ export type RootQuerySelector<T> = {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
export type ObjectQuerySelector<T> = T extends object ? {[key in keyof T]?: QuerySelector<T[key]> } : QuerySelector<T>;
|
||||
|
||||
export type Condition<T> = MongoAltQuery<T> | QuerySelector<MongoAltQuery<T>>;
|
||||
|
||||
export type FilterQuery<T> = {
|
||||
|
||||
@@ -7,7 +7,8 @@ async function run() {
|
||||
const db = client.db('test');
|
||||
|
||||
interface SubTestModel {
|
||||
field: string;
|
||||
field1: string;
|
||||
field2: string;
|
||||
}
|
||||
|
||||
// test with collection type
|
||||
@@ -106,6 +107,8 @@ async function run() {
|
||||
buildUpdateQuery({ $pull: { fruitTags: { $in: ['a'] } } });
|
||||
buildUpdateQuery({ $pull: { 'dot.notation': 1 } });
|
||||
buildUpdateQuery({ $pull: { 'subInterfaceArray.$[]': { $in: ['a'] } } });
|
||||
buildUpdateQuery({ $pull: { subInterfaceArray: { field1: 'a' } }});
|
||||
buildUpdateQuery({ $pull: { subInterfaceArray: { field1: { $in: ['a'] } } }});
|
||||
|
||||
buildUpdateQuery({ $push: { fruitTags: 'a' } });
|
||||
buildUpdateQuery({ $push: { fruitTags: { $each: ['a'] } } });
|
||||
|
||||
Reference in New Issue
Block a user