npm-medgo-query
v2.1.1
Published
You must provide a generated search function by using the `setGenerateSearch` method of the package. It must always have a default similar to the following. For your custom generation you can do as many things as you want.
Downloads
145
Maintainers
Keywords
Readme
Important to do when using
generateSearch
You must provide a generated search function by using the setGenerateSearch
method of the package.
It must always have a default similar to the following.
For your custom generation you can do as many things as you want.
function generateSearch(query: any, key: any): string {
switch (key) {
case "jobProfiles":
return (
"jobprofiles:" +
query[key]
.map((e: any): string =>
e.job !== -1
? e.specialtys.length > 0
? e.specialtys
.map((spec: any): string =>
e.institutions && e.institutions.length > 0
? e.institutions.map((i: any): string =>
("" + e.job).concat(
spec !== -1
? "s" + spec + (i !== -1 ? "s" + i : "")
: i !== -1
? "ss" + i
: ""
)
)
: ("" + e.job).concat(spec !== -1 ? "s" + spec : "")
)
.join(",")
: e.institutions && e.institutions.length > 0
? e.institutions.map((i: any): string => ("" + e.job).concat(i !== -1 ? "ss" + i : ""))
: ""
: ""
)
.filter((e: any): boolean => e !== "")
.join(",")
);
default:
return "" + key + ":" + query[key];
}
}
formatterslist
you can extend the formatters list with the extendFormatterslist
method of the package.
here's a quick example
// value will be the value of the variable isRadhiAGoodGuy in this example
// values are always string.
function booleanParser(value: string) {
return value === "true";
}
const formatterslist = {
isRadhiAGoodGuy: booleanParser
};
// Will do an object assign to add the new values you're using on top of the other parsers already defined in the package (check below for more)
extendFormatterslist(formatterslist);
List of formatters present in the module
let formatterslist = {
statut: splitStringAndParseInt,
job: splitStringAndParseInt,
jobProfilesPending: jobProfileParser2,
specialty: splitStringAndParseInt,
institution: splitStringAndParseInt,
admin: splitStringAndParseInt,
missionmotifcreationcategory: splitStringAndParseInt,
originInstitution: splitStringAndParseInt,
mission: splitStringAndParseInt,
id: splitStringAndParseInt,
worker: splitStringAndParseInt,
beginAt: unixRangeParser,
endAt: operatorNumberParser,
createdAt: operatorNumberParser,
jobprofiles: jobProfileParser,
searchname: searchNameParser,
populate: splitString,
isDeletedFromNetwork: booleanParser,
isDeletedFromNetworkByInstitutions: isDeletedFromNetworkParser,
isCanceled: booleanParser,
isFullTime: booleanParser,
isExpress: booleanParser,
isLongMission: booleanParser,
isPastMission: booleanParser,
isPlanning: booleanParser,
isValidated: booleanParser,
isFilled: booleanParser,
isNight: idBooleanParser,
isDay: idBooleanParser,
isDayRefused: idBooleanParser,
isNightRefused: idBooleanParser,
isSignedPerAdmin: booleanParser,
isSignedPerWorker: booleanParser,
isBlockedByAdmin: institutionServiceBooleanParser,
isRefusedByWorker: institutionServiceBooleanParser,
isWorkerNotified: idBooleanParser,
isAllowedDay: idBooleanParser,
isAllowedNight: idBooleanParser,
isAllowedService: institutionServiceBooleanParser,
service: splitStringAndParseInt,
range: rangeParser,
rangeBeginAt: rangeParser,
nbPotentialWorkers: operatorNumberParser,
isAccepted: booleanParser,
isRefused: booleanParser,
acceptedBy: splitStringAndParseInt,
createdBy: splitStringAndParseInt,
idInInstitution: splitString,
isViaEmailCSVOption: booleanParser,
isPoleCSVOption: booleanParser,
isRecupCSVOption: booleanParser,
isTwoLinesForMissionOnTwoDaysCSVOption: booleanParser,
idInfoOnWorkersCSVOption: splitStringAndParseInt,
inCluster: splitStringAndParseInt,
didWorkerSignUp: booleanParser,
contract: splitStringAndParseInt,
isCancelled: booleanParser,
isFused: booleanParser,
isSigned: booleanParser,
isCancelledOrFused: booleanParser,
isSignedOrNew: booleanParser,
isDayMission: booleanParser,
isPublicHoliday: booleanParser,
isSunday: booleanParser
};
For more information please check the source code to see how parsers work
Luxury
there's also an express middlware to put the req.query
request parameters in req.parameters
after parse with your configuration.
Version
2.1.1
- Escape single quotes in search input in queries
2.0.0
- Use "like" instead of "similar to". "Similar to" doesn't support comparing all characters.
- Fix where clause, string was truncated
1.0.0-beta.10
- Add isDayMission, isPublicHoliday, isSunday
1.0.0-beta.5
- Add package pg to dependencies
- Add package pg-native to dependencies
1.0.0-beta.3
- Add package pg-native
1.0.0-beta.1
- change paramParser for idInInstitution: expecting string instead of integer
1.0.0-beta.0
- new name the package changes its name to npm-medgo-query