Skip to content

@casl/mongoose usage with typegoose? #549

Answered by Alex0007
johnsonjo4531 asked this question in Q&A
Discussion options

You must be logged in to vote
import { AccessibleRecordModel } from "@casl/mongoose";
import { getModelForClass as getModelForClassOld } from "@typegoose/typegoose";
import { AnyParamConstructor, BeAnObject, IModelOptions } from "@typegoose/typegoose/lib/types";

export const getModelForClass = <
  U extends AnyParamConstructor<any>,
  QueryHelpers = BeAnObject
>(
  cl: U,
  options: IModelOptions
): AccessibleRecordModel<InstanceType<U>, QueryHelpers> & U => {
  return getModelForClassOld(cl, options) as any;
};

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@danielbayerlein
Comment options

@Alex0007
Comment options

@danielbayerlein
Comment options

@johnsonjo4531
Comment options

@johnsonjo4531
Comment options

Answer selected by johnsonjo4531
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants