api/mongo/grp/schema

This schema defines the GraphQL structure used to return GRP information. GRP defines a God Related Place, and it stores location information, schedules, names, and contributors.

api/mongo/grp/schema

api/mongo/grp/model

This module defines the main methods to create, validate, get different information related to a GRP, etc. Most if not all DB operations for GRPs should go thru method defined here.

api/mongo/grp/model

createGrp

This method adds timestamps updated/created to the input GRP, then it validated the input GRP and if nothing is incorrect it is stored in mongo.

createGrp(newGrp: Object)
Parameters
newGrp (Object) the object to be validated and stored

addGrpTimestamps

This method get the current time, and adds that time as both the created and updated properties.

addGrpTimestamps(grp: Object)
Parameters
grp (Object) a GRP object

updateGrpTimestamps

This method changes the updated field of a GRP to the current time

updateGrpTimestamps(grp: Object)
Parameters
grp (Object) a GRP object

getNextGrpDatesFromUntil

This method generates count number of dates from to until. The dates are generated based on the recurrences stored within the GRP schedules. All of these are retrieved and based on that all of the schedules are generated.

getNextGrpDatesFromUntil(grp: Object, count: Number, from: Date, end: Date, until: any): Array<Date>
Parameters
grp (Object) a GRP object
count (Number) an integer specifying the max number of dates that can be generated
from (Date) the starting date from which to generate dates.
end (Date) the ending date until which to generate dates.
until (any)
Returns
Array<Date>: the calculated dates

getGrpCollection

This method returns a promise to a Mongo Collection of GRP. The method will make sure to connect to the DB before returning the collection.

getGrpCollection(): Promise<Collection>
Returns
Promise<Collection>: a Mongo DB Collection

searchGrps

This is a resolver function as defined in Apollo's resolver docs it will return a promise which should return an array of GRPs if the function succesfully queried the DB.

searchGrps(_: undefined, parms: Object): Promise<Array<Object>>
Parameters
_ (undefined) takes nothing as the first input this is to ignore context
parms (Object) parameters to the searchGrps query function
Name Description
parms.name String? the name of the GRP where order and spaces don't matter
parms.polygon Object? A polygon represention using coordinates
parms.point Array<Float>? An array [ lat,lon ] specifying the coordinates of a point
parms.sortBy String? A String specifying the order by which to sort eg. TIME, BEST, etc.
parms.city String? A String specifying the name of a city (case, accent's, etc don't matter)
parms.state String? A String specifying the name of a state (case, accent's, etc don't matter)
parms.first Number? A Number for the 'first' number of GRPs to return
parms.after String? An opaque ID String specifying the offset from the 0's result of the query
Returns
Promise<Array<Object>>: the GRPs from search