-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Create examples
sub-project for something like plugin testing / showcase
#734
Comments
How can add plugin in my code? type PaginateMethod<T> = (
query?: FilterQuery<T>,
options?: PaginateOptions,
callback?: (err: any, result: PaginateResult<T>) => void
) => Promise<PaginateResult<T>>;
type AggregatePaginateMethod<T> = (
query?: Aggregate<T[]>,
options?: PaginateOptions,
callback?: (err: any, result: AggregatePaginateResult<T>) => void
) => Promise<AggregatePaginateResult<T>>;
@Plugins(paginate)
@Plugins(aggregatePaginate)
@Plugins(MongooseDelete, {
overrideMethods: "all",
deletedAt: true,
deletedBy: true,
})
export class BasicModel {
static paginate: PaginateMethod<typeof BasicModel>;
static aggregatePaginate: AggregatePaginateMethod<typeof BasicModel>;
} but for mongoose-delete I don't know how do this? I make: import MongooseDelete, { SoftDeleteModel } from "mongoose-delete";
export type ISoftDeleteModel<T, T2> = SoftDeleteModel<DocumentType<T>> & T & T2; and use other module: // any idea for add to base class?
import { BasicModel, ISoftDeleteModel } from "../base.model";
@ObjectType()
export class Member extends BasicModel {
@Field(() => GraphQLObjectID)
_id!: string;
@Field({ nullable: true })
@Property()
firstname?: string;
@Field()
@Property()
lastname?: string;
}
@ObjectType()
export class MemberData {
@Field(() => [Member])
docs?: Member[];
}
export const MemberModel = getModelForClass(Member, {
existingConnection: publicConnection,
schemaOptions: {
timestamps: true,
collection: "members",
},
}) as ISoftDeleteModel<Member, typeof Member>; any idea for add to base class? |
@hmz22 such a case (a plugin with custom model / document types) is definitely a thing i would like to add as a example, but this is not really the correct place to ask for this, the more correct place would be in discussions, also i dont really understand your question, please be more specific in what you want to achieve. |
mongoose-delete have Method overridden like countDeleted,... and when I use MemberMode.countDeleted type script show error this model haven't countDeleted and I must add |
i have created a repository: https://github.com/typegoose/typegoose-examples (it will not be a sub-directory) anyone can suggest packages or other case examples to add or submit a PR for examples (follow PS: will keep this issue open until some more examples are in the repository |
Describe what you need | want
Currently typegoose only has plugin testing with some specific plugins and the examples in the documentation are also not tested / updated, so i would propose to add a
examples
sub-project which houses full-working examples of either typegoose itself and / or with pluginsDo you have already an idea for the implementation?
see above
Plugins to maybe consider adding initially:
The text was updated successfully, but these errors were encountered: