Function queryMethod

  • Adds a query method to the Class which will then be added to the Schema.

    Type Parameters

    Parameters

    • func: ((this, ...params) => Query<any, any, {}, any, "find">)

      The Query Method to add

        • (this, ...params): Query<any, any, {}, any, "find">
        • Parameters

          Returns Query<any, any, {}, any, "find">

    Returns ClassDecorator

    Example

    interface FindHelpers {
    findByTitle: AsQueryMethod<typeof findByTitle>;
    }

    function findByTitle(this: ReturnModelType<typeof Event, FindHelpers>, title: string) {
    return this.find({ title });
    }

    @queryMethod(findByTitle)
    class Event {
    @prop()
    public title: string;
    }

    const EventModel = getModelForClass<typeof Event, FindHelpers>(Event);

Generated using TypeDoc