Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Document#createDocuments-like methods. #2998

Open
LukeAbby opened this issue Dec 29, 2024 · 0 comments
Open

Refactor Document#createDocuments-like methods. #2998

LukeAbby opened this issue Dec 29, 2024 · 0 comments

Comments

@LukeAbby
Copy link
Collaborator

Doing stuff like:

  static createDocuments<T extends Document.AnyConstructor, Temporary extends boolean | undefined>(
    this: T,
    data: Array<Document.ConstructorDataFor<NoInfer<T>>>,
    operation?: InexactPartial<
      Omit<Document.DatabaseOperationsFor<NoInfer<T>["metadata"]["name"], "create">, "data">
    > & {
      temporary?: Temporary;
    },
  ): Promise<Document.ToStoredIf<T, Temporary>[] | undefined>;

Is quite clever but it inhibits the ability to subclass it.
A more ideal situation would be one override per Document:

  static createDocuments<Temporary extends boolean | undefined>(
    data: Array<CurrentClass.ConstructorData>,
    operation?: InexactPartial<
      Omit<Document.DatabaseOperationsFor<"CurrentClass", "create">, "data">
    > & {
      temporary?: Temporary;
    },
  ): Promise<Document.StoredIf<CurrentClass, Temporary>[] | undefined>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant