Module DbService

This is the database service file This is the last step in the process and where we get the query results The functions here are GENERIC and are designed to work with all endpoints More functions can be added if additional functionality is needed The five functions are connectToDB queryUpload, querySearchAND, queryUpdate, and queryDeleteAND Any errors will be caught by our try/catch block in our controller

Properties

Properties

export=: {
    connectToDB: (() => Promise<void>);
    queryDeleteAND: ((filterValues: any, collection: any) => Promise<any>);
    querySearchAND: ((filterValues: any, collection: any) => Promise<any>);
    queryUpdate: ((searchCriteria: any, replaceCriteria: any, collection: any) => Promise<any>);
    queryUpload: ((inputObject: any, collection: any) => Promise<any>);
}

Type declaration

  • connectToDB: (() => Promise<void>)
      • (): Promise<void>
      • This code allows us to connect to the database Not sure how this works exactly, but it works

        Returns Promise<void>

  • queryDeleteAND: ((filterValues: any, collection: any) => Promise<any>)
      • (filterValues: any, collection: any): Promise<any>
      • This function deletes an object or objects that match the filterValues

        Parameters

        • filterValues: any

          These are the values we will search by to delete objects Value should only be an id or a unique value unless we want to do a bulk delete

        • collection: any

          this is the puzzle schema which dictates the collection as well as the Mongoose schema that will be used to upload our object

        Returns Promise<any>

  • querySearchAND: ((filterValues: any, collection: any) => Promise<any>)
      • (filterValues: any, collection: any): Promise<any>
      • This function searches for objects with the $and operator

        Parameters

        • filterValues: any

          this provides the parameters with which we can search for puzzles to retrieve

        • collection: any

          this is the puzzle schema which dictates the collection as well as the Mongoose schema that will be used to upload our object

        Returns Promise<any>

  • queryUpdate: ((searchCriteria: any, replaceCriteria: any, collection: any) => Promise<any>)
      • (searchCriteria: any, replaceCriteria: any, collection: any): Promise<any>
      • This function updates or patches an object or objects with the replaceCriteria

        Parameters

        • searchCriteria: any

          This is the criteria we use to select the objects we need to update

        • replaceCriteria: any

          This is the values that we will replace inside the object, leaving the remaining values untouched

        • collection: any

          this is the puzzle schema which dictates the collection as well as the Mongoose schema that will be used to upload our object

        Returns Promise<any>

  • queryUpload: ((inputObject: any, collection: any) => Promise<any>)
      • (inputObject: any, collection: any): Promise<any>
      • This function uploads an array of objects to the database ordered: false means that the function will attempt to upload all objects instead of stopping at failure

        Parameters

        • inputObject: any

          this is the input object which will be uploaded to the database

        • collection: any

          this is the puzzle schema which dictates the collection as well as the Mongoose schema that will be used to upload our object

        Returns Promise<any>

Generated using TypeDoc