Skip to content

Instantly share code, notes, and snippets.

@guillett
Last active April 22, 2022 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guillett/91bb30fc1fb667484673fe2967b086c5 to your computer and use it in GitHub Desktop.
Save guillett/91bb30fc1fb667484673fe2967b086c5 to your computer and use it in GitHub Desktop.
Requête médicosocial
db.getCollection('simulations').mapReduce(function() {
var propAnswer1 = this.answers.current.find(function(e) {
return e.fieldName === "_formationSanitaireSocial"
})
var propAnswer2 = this.answers.current.find(function(e) {
return e.fieldName === "_interetAidesSanitaireSocial"
})
var group = this.dateDeValeur.toISOString().slice(0,4)
var v1 = propAnswer1 ? propAnswer1.value : "#N/A"
var v2 = propAnswer2 ? propAnswer2.value : "#N/A"
emit(group + ";" + v1 + ";" + v2, 1)
}, function(k,v) {
return Array.sum(v);
}, {
query: {
//dateDeValeur: { $gt: ISODate('2022-04-10') },
},
out: { inline: 1 },
}).results.map(function(o) {
return o._id + ";" + o.value;
}).join('\n')
periode _formationSanitaireSocial _interetAidesSanitaireSocial nombre
2021 #N/A #N/A 117076
2022 #N/A #N/A 184061
2022 #N/A false 11299
2022 #N/A true 4922
2022 false #N/A 71
2022 false false 9568
2022 false true 2374
2022 true #N/A 1256
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment