Skip to content

Commit 1a23d06

Browse files
committed
Optimize groups performance
1 parent c34c42e commit 1a23d06

File tree

5 files changed

+198
-434
lines changed

5 files changed

+198
-434
lines changed

Diff for: src/types/core.ts

+23-18
Original file line numberDiff line numberDiff line change
@@ -1222,35 +1222,40 @@ export namespace TypesaurusCore {
12221222
infer CustomName
12231223
>
12241224
? NestedCollection<
1225-
{
1226-
Model: NullifyModel<Model>;
1227-
Name: CustomName extends string ? CustomName : Name;
1228-
Id: CustomId extends Id<any> | string
1229-
? CustomId
1230-
: Id<Utils.ComposePath<BasePath, Name>>;
1231-
WideModel: NullifyModel<Model>;
1232-
Flags: DocDefFlags;
1233-
},
1225+
CollectionDef<Name, Model, CustomId, CustomName, BasePath>,
12341226
DB<Schema, Utils.ComposePath<BasePath, Name>>
12351227
>
12361228
: Schema[Name] extends PlainCollection<
12371229
infer Model,
12381230
infer CustomId,
12391231
infer CustomName
12401232
>
1241-
? Collection<{
1242-
Model: NullifyModel<Model>;
1243-
Name: CustomName extends string ? CustomName : Name;
1244-
Id: CustomId extends Id<any> | string
1245-
? CustomId
1246-
: Id<Utils.ComposePath<BasePath, Name>>;
1247-
WideModel: NullifyModel<Model>;
1248-
Flags: DocDefFlags;
1249-
}>
1233+
? Collection<
1234+
CollectionDef<Name, Model, CustomId, CustomName, BasePath>
1235+
>
12501236
: never
12511237
: never;
12521238
};
12531239

1240+
/**
1241+
* Resolves collection def.
1242+
*/
1243+
export type CollectionDef<
1244+
Name extends string,
1245+
Model extends ModelType,
1246+
CustomId,
1247+
CustomName,
1248+
BasePath extends string | false,
1249+
> = {
1250+
Model: NullifyModel<Model>;
1251+
Name: CustomName extends string ? CustomName : Name;
1252+
Id: CustomId extends Id<any> | string
1253+
? CustomId
1254+
: Id<Utils.ComposePath<BasePath, Name>>;
1255+
WideModel: NullifyModel<Model>;
1256+
Flags: DocDefFlags;
1257+
};
1258+
12541259
/**
12551260
* Infers schema types. Useful to define function arguments that accept
12561261
* collection doc, ref, id or data.

0 commit comments

Comments
 (0)