Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
Roosteridk authored Dec 19, 2022
1 parent 3ec8c12 commit 3442fe1
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ interface Updates<Schema> {
/**Fields to update*/
set?: Partial<Schema>;
/**Fields to increment by a number.*/
increment?: Record<KeysMatching<Schema, number>, number>;
increment?: Partial<Record<KeysMatching<Schema, number>, number>>;
/**Fields to append a list of values*/
append?: Record<KeysMatching<Schema, []>, unknown[]>;
append?: Partial<Record<KeysMatching<Schema, []>, unknown[]>>;
/**Fields to prepend a list of values*/
prepend?: Record<KeysMatching<Schema, []>, unknown[]>;
prepend?: Partial<Record<KeysMatching<Schema, []>, unknown[]>>;
/**List of fields to remove*/
delete?: (keyof Schema)[];
}
Expand All @@ -150,8 +150,11 @@ interface QueryResponse<Schema> {
items: Schema[];
}

// Utility type from https://stackoverflow.com/questions/56863875/typescript-how-do-you-filter-a-types-properties-to-those-of-a-certain-type
// Filters out all the keys of an object that are not of a certain type
// Utility types
/**
* Get the keys of an object that match a given type
* https://stackoverflow.com/questions/56863875/typescript-how-do-you-filter-a-types-properties-to-those-of-a-certain-type
*/
type KeysMatching<T extends object, V> = {
[K in keyof T]-?: [V] extends [T[K]] ? K : never
}[keyof T];

0 comments on commit 3442fe1

Please sign in to comment.