Skip to content

Commit

Permalink
feat: n'a pas fonctionné en tir groupé
Browse files Browse the repository at this point in the history
  • Loading branch information
alanlr committed Jul 3, 2024
1 parent c3a6866 commit 73f3af8
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions server/src/db/migrations/20240628000000-deca.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const up = async (db: Db, _client: MongoClient) => {
{ bypassDocumentValidation: true }
);

const command = {
const command_1 = {
aggregate: "deca",
pipeline: [
{
Expand All @@ -18,6 +18,28 @@ export const up = async (db: Db, _client: MongoClient) => {
"alternant.sexe": {
$toString: "$alternant.sexe",
},
},
},
{
$merge: {
into: "deca",
whenMatched: "merge",
whenNotMatched: "fail",
},
},
],
cursor: {},
bypassDocumentValidation: true,
};

await _client.db("mna-bal").command(command_1);

const command_2 = {
aggregate: "deca",
pipeline: [
{ $match: { "alternant.adresse.numero": { $ne: null } } },
{
$addFields: {
"alternant.adresse.numero": {
$toInt: "$alternant.adresse.numero",
},
Expand All @@ -35,7 +57,7 @@ export const up = async (db: Db, _client: MongoClient) => {
bypassDocumentValidation: true,
};

await _client.db("mna-bal").command(command);
await _client.db("mna-bal").command(command_2);

await db.collection("deca").updateMany(
{ "alternant.sexe": { $in: ["1", "2"] } },
Expand Down

0 comments on commit 73f3af8

Please sign in to comment.