Options
All
  • Public
  • Public/Protected
  • All
Menu

Module crud/server

Index

References

CreateInput

Re-exports CreateInput

CreateVariables

Re-exports CreateVariables

DefaultMutatorName

Re-exports DefaultMutatorName

DeleteInput

Re-exports DeleteInput

DeleteVariables

Re-exports DeleteVariables

FilterableInput

Re-exports FilterableInput

UpdateInput

Re-exports UpdateInput

UpdateVariables

Re-exports UpdateVariables

VulcanSelector

Re-exports VulcanSelector

Type aliases

UpdateMutatorInput

UpdateMutatorInput: UpdateMutatorCommonInput & DataIdInput | VulcanInput | SelectorInput

Functions

convertIdAndTransformToJSON

  • convertIdAndTransformToJSON<TModel>(doc: MongoDoc<TModel>): TModel & { _id: string }
  • convertIdAndTransformToJSON<TModel>(docs: MongoDoc<TModel>[]): (TModel & { _id: string })[]
  • Converts Mongo ObjectId to string

    NOTE: technically this would work for any kind of collection that return Ids with "toString" method, that's why it belongs to the generic "CRUD" package

    Connectors are expected to use string ids It was the default behaviour in Meteor for Mongo, but Mongoose/raw Mongo default behaviour is to use ObjectId

    Also needed in default resolvers when calling a data source

    => we prefer string ids in Vulcan for a consistent representation, in particular between the GraphQL client (that will always use string ids) and the server

    deprecated

    Do not convert _id in connector, but instead prefer a graphql scalar server-side

    Type parameters

    • TModel: VulcanDocument

    Parameters

    • doc: MongoDoc<TModel>

    Returns TModel & { _id: string }

  • Type parameters

    • TModel: VulcanDocument

    Parameters

    • docs: MongoDoc<TModel>[]

    Returns (TModel & { _id: string })[]

convertToJSON

  • convertToJSON<TModel>(doc: MongoDoc<TModel>): TModel & { _id: MongoId }
  • convertToJSON<TModel>(docs: MongoDoc<TModel>[]): (TModel & { _id: MongoId })[]
  • Converts Mongoose document to JSON result

    /!\ The _id is still an ObjectId, but you should not care

    NOTE: technically this would work for any kind of collection that return Ids with "toString" method, that's why it belongs to the generic "CRUD" package

    Connectors are expected to use string ids It was the default behaviour in Meteor for Mongo, but Mongoose/raw Mongo default behaviour is to use ObjectId

    Also needed in default resolvers when calling a data source

    => we prefer string ids in Vulcan for a consistent representation, in particular between the GraphQL client (that will always use string ids) and the server

    Type parameters

    • TModel: VulcanDocument

    Parameters

    • doc: MongoDoc<TModel>

    Returns TModel & { _id: MongoId }

  • Type parameters

    • TModel: VulcanDocument

    Parameters

    • docs: MongoDoc<TModel>[]

    Returns (TModel & { _id: MongoId })[]

Const createMutator

  • createMutator<TModel>(__namedParameters: CreateMutatorInput): Promise<{ data: TModel }>
  • Create a new object

    Will run permissions check, and callbacks tied to a model

    Type parameters

    • TModel: VulcanDocument

    Parameters

    • __namedParameters: CreateMutatorInput

    Returns Promise<{ data: TModel }>

Const dataToModifier

  • dataToModifier(data: VulcanDocument): Modifier
  • Parameters

    • data: VulcanDocument

    Returns Modifier

Const deleteMutator

  • deleteMutator<TModel>(__namedParameters: DeleteMutatorCommonInput & { dataId: string; input?: undefined; selector?: undefined } & DeleteMutatorCommonInput & { dataId?: undefined; input?: undefined; selector: Object } & DeleteMutatorCommonInput & { dataId?: undefined; input: DeleteInput; selector?: undefined }): Promise<{ data: TModel }>
  • Type parameters

    • TModel: VulcanDocument

    Parameters

    • __namedParameters: DeleteMutatorCommonInput & { dataId: string; input?: undefined; selector?: undefined } & DeleteMutatorCommonInput & { dataId?: undefined; input?: undefined; selector: Object } & DeleteMutatorCommonInput & { dataId?: undefined; input: DeleteInput; selector?: undefined }

    Returns Promise<{ data: TModel }>

Const getUnusedSlug

  • getUnusedSlug(connector: Connector<any, any, any, any>, slug: any, documentId: any): Promise<undefined | string>
  • summary

    Given a collection and a slug, returns the same or modified slug that's unique within the collection; It's modified by appending a dash and an integer; eg: my-slug => my-slug-1

    Parameters

    • connector: Connector<any, any, any, any>
    • slug: any
    • documentId: any

    Returns Promise<undefined | string>

    The slug passed in the 2nd param, but may be

Const modifierToData

  • modifierToData(modifier: Modifier): VulcanDocument
  • Parameters

    • modifier: Modifier

    Returns VulcanDocument

Const performMutationCheck

  • performMutationCheck(options: MutationCheckOptions): void
  • Parameters

    • options: MutationCheckOptions

    Returns void

Const updateMutator

  • Type parameters

    • TModel: VulcanDocument

    Parameters

    Returns Promise<{ data: TModel }>

Const validateData

  • validateData(__namedParameters: ValidateDataInput): ValidationError[]
  • Parameters

    • __namedParameters: ValidateDataInput

    Returns ValidationError[]

Const validateMutationData

  • validateMutationData(__namedParameters: { currentUser?: any; data?: any; model: VulcanCrudModelServer<any>; mutatorName: DefaultMutatorName; originalDocument?: VulcanDocument; properties: Partial<CreateMutatorProperties & UpdateMutatorProperties>; validationFunction?: Function }): Promise<void>
  • Throws if some data are invalid

    Parameters

    • __namedParameters: { currentUser?: any; data?: any; model: VulcanCrudModelServer<any>; mutatorName: DefaultMutatorName; originalDocument?: VulcanDocument; properties: Partial<CreateMutatorProperties & UpdateMutatorProperties>; validationFunction?: Function }
      • Optional currentUser?: any
      • Optional data?: any
      • model: VulcanCrudModelServer<any>
      • mutatorName: DefaultMutatorName
      • Optional originalDocument?: VulcanDocument
      • properties: Partial<CreateMutatorProperties & UpdateMutatorProperties>
      • Optional validationFunction?: Function

    Returns Promise<void>

Generated using TypeDoc