Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migration preparation & global package upgrade for mongodb V7 #1281

Merged
merged 117 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
f623c4c
feat: add mongodb utils
kevbarns Apr 27, 2024
e18a202
feat: add decriptor export model
kevbarns Apr 27, 2024
3e54891
feat: comment awaiting features
kevbarns Apr 29, 2024
40104aa
fix: remove duplicate collection name
kevbarns Apr 29, 2024
4362f23
feat: prepare models export
kevbarns Apr 29, 2024
5e0358d
fix: sort and remove unused
kevbarns Apr 29, 2024
1f213cc
feat: prepare server switch
kevbarns Apr 29, 2024
d2a0d08
fix: dedupe
kevbarns Apr 29, 2024
62207a5
feat: add indexes creation jobs
kevbarns Apr 29, 2024
52f4eb4
fix: comment
kevbarns Apr 29, 2024
2757012
feat: update createIndex function
kevbarns Apr 29, 2024
d9137f7
feat: prepare db switch for tests
kevbarns Apr 29, 2024
35ff39a
chore: skip test for now
kevbarns Apr 29, 2024
b083881
feat: update package & connector
kevbarns May 6, 2024
0a16df9
fix: shared
kevbarns May 6, 2024
9d051c8
fix: typing p1
kevbarns May 6, 2024
1cb6f77
fix: typing p2
kevbarns May 7, 2024
67a2a48
feat: update mongodb shared
kevbarns May 7, 2024
c5b3066
fix: revert
kevbarns May 7, 2024
53e75f6
Merge branch 'main' into feat-migration-mongodb
kevbarns May 28, 2024
ea5f225
Merge branch 'feat-lbac-2148-mongodb-v6+' into feat-migration-mongodb…
kevbarns May 28, 2024
cf3e50d
fix: bson version
kevbarns May 29, 2024
41eb4f1
fix: zod version + add & export zod-mongodb-schema to shared
kevbarns May 31, 2024
7a00415
feat: update mongodb driver to match bson
kevbarns May 31, 2024
bd7cf35
fix: typecheck
kevbarns May 31, 2024
2fbf8bf
feat: update zod ui
kevbarns May 31, 2024
99141c3
fix: zod typing
kevbarns May 31, 2024
3e345ab
feat: update openapi snapshot
kevbarns May 31, 2024
8b5ebd1
feat: update route & snapshot
kevbarns May 31, 2024
66898f6
fix: test
kevbarns May 31, 2024
24af7d1
fix: dedupe
kevbarns May 31, 2024
7bb22fe
fix: unskip test
kevbarns May 31, 2024
e56a5d2
Merge branch 'main' into feat-migration-mongodb+v6-merged
kevbarns May 31, 2024
5fb936d
fix: missing _id in pointgeometry definition
kevbarns May 31, 2024
c6258bb
fix: _id geopoint can be nullish at creation
kevbarns May 31, 2024
39b6859
fix: remove _id directly from schema
kevbarns May 31, 2024
428ebf8
fix: remove _id from definition
kevbarns May 31, 2024
675310c
fix: bson compatibility error
kevbarns May 31, 2024
9ae061b
fix: start jobs after mongoose
kevbarns Jun 1, 2024
15c9abd
fix: mongodb connection
kevbarns Jun 3, 2024
e3b529e
fix: admin flow activate/desactivate
kevbarns Jun 10, 2024
06468d8
fix: user validation flow
kevbarns Jun 10, 2024
9607d08
fix: admin get user
kevbarns Jun 10, 2024
7b4e519
fix: simplification du typage de l'api getDbCollection (#1292)
remy-auricoste Jun 11, 2024
d21b525
fix: update job statut from admin
kevbarns Jun 11, 2024
b1e95ce
feat: remove log & update /user/opco mongo query
kevbarns Jun 11, 2024
eb650dc
fix: Lbac 2259 migration mongodb lot 3 (#1296)
remy-auricoste Jun 13, 2024
c90442f
feat: lbac 2257: migration appels mongodb lot1 (#1294)
kevbarns Jun 13, 2024
c6e71c2
feat: remove application model
kevbarns Jun 14, 2024
ba69ea0
feat: LBA-2258 lot 2 (#1293)
alanlr Jun 17, 2024
660b8f1
feat: remove mongoose file
kevbarns Jun 17, 2024
2fef7a0
refactor: migrate types & services
kevbarns Jun 17, 2024
7fa4093
feat: update create index jobs & remove mongodb legacy connector
kevbarns Jun 17, 2024
8d97b56
fix: typecheck
kevbarns Jun 17, 2024
c5d2162
fix: async iterable
kevbarns Jun 17, 2024
b5d0c4c
fix: objectid import
kevbarns Jun 17, 2024
84fff90
fix: job processor db calls
kevbarns Jun 18, 2024
de29fa1
fix: jobs export to pe
kevbarns Jun 18, 2024
1f92d30
fix: sentry
kevbarns Jun 18, 2024
69c61ee
fix: test
kevbarns Jun 18, 2024
c85e72e
fix: job processor
kevbarns Jun 18, 2024
56cb96c
Merge branch main into feat-migration-mongodb+v6-merged
kevbarns Jun 19, 2024
c2add1c
fix: missing zod
kevbarns Jun 19, 2024
087ed49
fix: issues
kevbarns Jun 19, 2024
f6141b4
fix: issues
kevbarns Jun 19, 2024
c02cabf
fix: issues
kevbarns Jun 19, 2024
f575185
feat: update ts and use mongodb objectid
kevbarns Jun 19, 2024
dcc1908
fix: ui type never
kevbarns Jun 19, 2024
78bb8dc
fix: organization
kevbarns Jun 19, 2024
e7473e1
feat: update mongoutils
kevbarns Jun 19, 2024
be2be6a
feat: update eslint package
kevbarns Jun 19, 2024
3d485c9
fix: eslint p1
kevbarns Jun 20, 2024
2d922d9
fix: eslint p2
kevbarns Jun 20, 2024
68bc6bd
fix: eslint p3
kevbarns Jun 20, 2024
c8eedfa
Merge branch 'main' into feat-migration-mongodb+v6-merged
kevbarns Jun 20, 2024
0e5ba02
fix: updateSAVE
kevbarns Jun 20, 2024
eefe291
fix: yarn.lock
kevbarns Jun 20, 2024
ab034d8
Merge branch 'main' into feat-migration-mongodb+v6-merged
kevbarns Jun 20, 2024
052b60d
Merge branch 'main' into feat-migration-mongodb+v6-merged
kevbarns Jun 20, 2024
59ad6a1
Merge branch 'main' into feat-migration-mongodb+v6-merged
kevbarns Jun 20, 2024
0315366
Merge branch 'main' into feat-migration-mongodb+v6-merged
kevbarns Jun 20, 2024
1c6d9c9
fix: sentry init
kevbarns Jun 20, 2024
129090d
fix: sentry config
kevbarns Jun 24, 2024
0eb37a7
fix: job processor
kevbarns Jun 24, 2024
460c31d
fix: cron scheduler
kevbarns Jun 24, 2024
d94698a
feat: remove mongoose
kevbarns Jun 24, 2024
4b1ac6a
fix: yarn.lock
kevbarns Jun 24, 2024
2ea2a09
Merge branch 'main' into feat-migration-mongodb+v6-merged
kevbarns Jun 25, 2024
067e74c
fix: index script
kevbarns Jun 25, 2024
2af6367
Merge branch 'feat-migration-mongodb+v6-merged' of github.com:mission…
kevbarns Jun 25, 2024
73026fe
fix(front): remove listener method
kevbarns Jun 25, 2024
91810d5
fix: etablissement creation operator
kevbarns Jun 25, 2024
adba9ea
fix: formulaire creation
kevbarns Jun 25, 2024
82c179f
fix: correction émission de candidature vers offre lba
alanlr Jun 25, 2024
25645a4
feat: update pentest mongodb uri
kevbarns Jun 25, 2024
06abfaf
fix: suppression ajout event parasite
alanlr Jun 25, 2024
13d2317
fix: script command
kevbarns Jun 25, 2024
563f3c6
Merge branch 'feat-migration-mongodb+v6-merged' of github.com:mission…
kevbarns Jun 25, 2024
fd62c5c
fix: missing 2dsphere indexes
kevbarns Jun 25, 2024
bf6cb60
fix: preview
kevbarns Jun 26, 2024
9ac9478
fix: revert fix
kevbarns Jun 26, 2024
a5e8e75
fix: obfuscate script
kevbarns Jun 26, 2024
ed514b9
fix: user update
kevbarns Jun 26, 2024
1801d51
fix: missing status
kevbarns Jun 26, 2024
2ba102e
fix: job update
kevbarns Jun 26, 2024
15b7723
fix: updatedAt
kevbarns Jun 26, 2024
a1d3107
fix: updates
kevbarns Jun 26, 2024
fb6e528
fix: update etfa email
kevbarns Jun 26, 2024
30a023f
fix: update personal info
kevbarns Jun 26, 2024
934c467
feat: update recette db uri
kevbarns Jun 27, 2024
951aefa
fix: appointment reply issue
kevbarns Jun 27, 2024
158d1a5
fix: atomic operator updateMany
kevbarns Jun 27, 2024
512c0b9
Merge branch 'main' into feat-migration-mongodb+v6-merged
kevbarns Jun 27, 2024
2d12a85
feat(lbac-2225): jobId as string
kevbarns Jun 28, 2024
6680329
fix: aggregate
kevbarns Jun 28, 2024
b5f7761
fix: remove address_detail
kevbarns Jun 28, 2024
684b0c8
fix: merge aggretate to array
kevbarns Jun 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bin/scripts/seed-apply.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ cat "$SEED_GZ" | docker compose -f "$ROOT_DIR/docker-compose.yml" exec -iT mongo
yarn build:dev
yarn cli migrations:up
yarn cli mongodb:indexes:create
# yarn cli recreate:indexes // when migration to V7 to replace with above
1 change: 1 addition & 0 deletions .bin/scripts/seed-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ mkdir -p "$ROOT_DIR/.infra/files/mongodb"
yarn build:dev
yarn cli migrations:up
yarn cli mongodb:indexes:create
# yarn cli recreate:indexes // when migration to V7 to replace with above

docker compose -f "$ROOT_DIR/docker-compose.yml" exec -it mongodb mongodump --uri "$TARGET_DB" --gzip --archive > "$SEED_GZ"
rm -f "$SEED_GPG"
Expand Down
1 change: 1 addition & 0 deletions .bin/scripts/setup-local-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ yarn setup:mongodb
yarn build:dev
yarn cli migrations:up
yarn cli mongodb:indexes:create
# yarn cli recreate:indexes // when migration to V7 to replace with above
16 changes: 10 additions & 6 deletions .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fileignoreconfig:
- filename: .bin/scripts/set-cypress-env.sh
checksum: 4463ed7c1d5b82a8b152248b953778f37771bfba72865ee0e8af3b61cf3c38da
- filename: .bin/scripts/setup-local-env.sh
checksum: f3cd7443153a8d4bc742ea6075b2ea9a174572b736186c6759fbf29f59567fd8
checksum: 7d480e0c37b177c4d84fb58b915da6495db0bb0fcd5996e0b3cf67d955929144
- filename: .github/workflows/cypress.yml
checksum: 39f98fb68fdebf6a36959706adb43a8219a4b7781ac35329f957dc1cfa8b6de0
- filename: .github/workflows/deploy_preview.yml
Expand All @@ -28,7 +28,7 @@ fileignoreconfig:
- filename: .infra/local/mongod.conf
checksum: bb2ce0c27102259a5fa39da1fb4460af9ad6ad58adc715312e53dcd69c8e6be7
- filename: .infra/vault/vault.yml
checksum: 6926cc583e24275ba52513ce9fd2559316f6bc75d5e869f9ed0e8c10d6b9f617
checksum: 7b101f10db1e047f483ba510e901723e59f54a92a54a059c1240cc9ae3f81f82
- filename: docker-compose.yml
checksum: 8cdd1da6c1155f26b417a27e26311d4f00b7d8bd6c21f1f86c1c7cb3f0599e6a
- filename: server/.env.test
Expand All @@ -40,17 +40,17 @@ fileignoreconfig:
- filename: server/src/db/migrations/20231127120528-remove-password.ts
checksum: 5c7a2ec4655f0543f42bfbccc759bff4eb10456946885531c91107cac3e8dbc0
- filename: server/src/db/migrations/202405230000000-migrate-fix-missing-date-blacklist.ts
checksum: 967bd89c16914bc70cf25d886d9800fb6fddcd53a8b87a1e78bda1c2167897ba
checksum: 0c1b814245a58b8ca788fbfab9899206edbddaae795d56963f86c5aa83ea555f
- filename: server/src/http/controllers/appointments/appointments.controller.ts
checksum: dc77c04efc26dcd8ca4816f392ab24a32a92cb45ca4b94adb593a08e7a2d231e
- filename: server/src/http/routes/appointmentRequest.controller.ts
checksum: d2770daa97ae332eec0b66497fdb717229895583ac3bfd48af1a830b36504968
- filename: server/src/http/routes/auth/password.controller.ts
checksum: 0eb3948d875508edf6d31f0ffe1290aac0cc02c9c80c913bcb04a312edd062cc
- filename: server/src/jobs/database/obfuscateCollections.ts
checksum: 9b7aa9538398882159db97f7d271a37ff368cc73faa184993dc9ce13a088950e
checksum: df959adedd069bbfd68c6c5c99a9f506b980147a973f95b517c24e740d79ee37
- filename: server/src/jobs/job.actions.ts
checksum: d716e214d828109181a138f0ae253d5489a3c544b2625917b458d1e07886c408
checksum: 40c0dfd4f33ec0f09d736e3e7554b0edee132165e1eb00440e196edf49e0c647
- filename: server/src/jobs/lba_recruteur/formulaire/misc/removeVersionKeyFromRecruiters.ts
checksum: 3cd111d8c109cfec357bae48af70d0cf5644d02cd2c4b9afc5b8aa07bccbd535
- filename: server/src/security/accessTokenService.ts
Expand Down Expand Up @@ -86,7 +86,7 @@ fileignoreconfig:
- filename: shared/helpers/generateUri.ts
checksum: 6542db0d3eca959c6e81d574f8b71d4b18d2f1af21042ca5ed4dff319cd39555
- filename: shared/helpers/openapi/__snapshots__/generateOpenapi.test.ts.snap
checksum: 527b5cc9cabe1009b736f2d2ab6da0b1f87f5536926a692c3a7e94cdee5d2e8a
checksum: caa1131ffe2f23d62ba2d4370173cce74ffa05a17330c8d342c41c4b971c6f9f
- filename: shared/helpers/openapi/generateOpenapi.test.ts
checksum: d7b85c3dff488cec523d78f0926e15dbea41071a1864bda62b4d6caeb2541df3
- filename: shared/models/applications.model.ts
Expand Down Expand Up @@ -141,6 +141,10 @@ fileignoreconfig:
checksum: 1ad48425b890a5ed3de19d079692e2ef7eac76483339a469a6cd9bc6d796ad26
- filename: ui/utils/api.utils.ts
checksum: 324cd501354cfff65447c2599c4cc8966aa8aac30dda7854623dd6f7f7b0d34e
- filename: ui/components/ItemDetail/LbaJobComponents/LbaJobTechniques.tsx
checksum: 553720667140e5bbf7cef1969c02cbcd3c234defc30bb08208398c1900e29e3b
- filename: server/src/http/sentry.ts
checksum: efa665e02ca4d3acbf48c5dc549dae4e915c02ae0626bedf71e3608f8d5e5ebd
scopeconfig:
- scope: node
custom_patterns:
Expand Down
8 changes: 5 additions & 3 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"axios-cache-interceptor": "^1.3.2",
"basic-ftp": "^5.0.3",
"boom": "^7.3.0",
"bson": "^6.7.0",
"bunyan": "^1.8.15",
"bunyan-slack": "^0.0.10",
"burner-email-providers": "^1.0.67",
Expand Down Expand Up @@ -71,8 +72,8 @@
"migrate-mongo": "^11.0.0",
"miniget": "^4.2.3",
"mjml": "^4.14.1",
"mongodb": "^3.7.4",
"mongoose": "^5.13.20",
"mongodb": "^6.7.0",
"mongoose": "^7.4.0",
"netmask": "^2.0.2",
"nodemailer": "^6.9.5",
"nodemailer-html-to-text": "^3.2.0",
Expand All @@ -89,7 +90,8 @@
"type-fest": "^4.18.2",
"xlsx": "^0.18.5",
"xml2js": "^0.6.2",
"zod": "3.21.4"
"zod": "3.23.8",
"zod-mongodb-schema": "^1.0.2"
},
"devDependencies": {
"@sentry/types": "^7.72.0",
Expand Down
10 changes: 3 additions & 7 deletions server/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { closeMongoConnection } from "@/common/mongodb"
import { closeMemoryCache } from "./common/apis/client"
import { logger } from "./common/logger"
import { sleep } from "./common/utils/asyncUtils"
import { closeMongodbConnection } from "./common/utils/mongodbUtils"
import { notifyToSlack } from "./common/utils/slackUtils"
import config from "./config"
import { closeSentry, initSentryProcessor } from "./http/sentry"
Expand Down Expand Up @@ -70,7 +71,7 @@ program
logger.info(`Starting command ${command}`)
})
.hook("postAction", async () => {
await Promise.all([closeMongoConnection(), closeMemoryCache()])
await Promise.all([closeMongoConnection(), closeMongodbConnection(), closeMemoryCache()])
await closeSentry()

setTimeout(async () => {
Expand Down Expand Up @@ -164,6 +165,7 @@ function createJobAction(name) {
}
}

program.command("recreate:indexes").description("Recreate MongoDB indexes").option("-q, --queued", "Run job asynchronously", false).action(createJobAction("recreate:indexes"))
program.command("db:validate").description("Validate Documents").option("-q, --queued", "Run job asynchronously", false).action(createJobAction("db:validate"))

program
Expand Down Expand Up @@ -574,12 +576,6 @@ program
.requiredOption("--from-date <string>, [fromDate]", "format DD-MM-YYYY. Date depuis laquelle les prises de rendez-vous sont renvoyéees")
.action(createJobAction("prdv:emails:resend"))

program
.command("migrate-multi-compte")
.description("Migre les données vers les tables multi-compte")
.option("-q, --queued", "Run job asynchronously", false)
.action(createJobAction("migrate-multi-compte"))

export async function startCLI() {
await program.parseAsync(process.argv)
}
106 changes: 31 additions & 75 deletions server/src/common/model/schema/appointments/appointment.schema.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,37 @@
import { IAppointment } from "shared"
import { IAppointment, IMailing } from "shared"
import { AppointmentUserType } from "shared/constants/appointment"

import { model, Schema } from "../../../mongodb"
import { mongoosePagination, Pagination } from "../_shared/mongoose-paginate"

const mailSchema = new Schema<IMailing>({
campaign: {
type: String,
default: null,
description: "Identifiant de campagne",
},
message_id: {
type: String,
default: null,
description: "Identifiant Brevo",
},
status: {
type: String,
default: null,
description: "Code erreur Brevo",
},
webhook_status_at: {
type: Date,
default: null,
description: "Date fournie par les webhooks Brevo lors de la réception d'un event",
},
email_sent_at: {
type: Date,
default: null,
description: "Date de création de la collection",
},
})

export const appointmentSchema = new Schema<IAppointment>(
{
applicant_id: {
Expand Down Expand Up @@ -59,80 +87,8 @@ export const appointmentSchema = new Schema<IAppointment>(
default: null,
description: "Date à laquelle le CFA à consulté la page contenant les informations du rendez et du candidat",
},
to_applicant_mails: {
type: "array",
description: "Liste des évènements MAIL récupéré par le serveur",
required: false,
default: [],
items: {
type: "object",
required: false,
properties: {
campaign: {
type: "string",
default: null,
description: "Identifiant de campagne",
},
message_id: {
type: "string",
default: null,
description: "Identifiant Brevo",
},
status: {
type: "string",
default: null,
description: "Code erreur Brevo",
},
webhook_status_at: {
type: Date,
default: null,
description: "Date fournie par les webhooks Brevo lors de la réception d'un event",
},
email_sent_at: {
type: Date,
default: null,
description: "Date de création de la collection",
},
},
},
},
to_cfa_mails: {
type: "array",
description: "Liste des évènements MAIL récupéré par le serveur",
required: false,
default: [],
items: {
type: "object",
required: false,
properties: {
campaign: {
type: "string",
default: null,
description: "Identifiant de campagne",
},
message_id: {
type: "string",
default: null,
description: "Identifiant Brevo",
},
status: {
type: "string",
default: null,
description: "Code erreur Brevo",
},
webhook_status_at: {
type: Date,
default: null,
description: "Date fournie par les webhooks Brevo lors de la réception d'un event",
},
email_sent_at: {
type: Date,
default: null,
description: "Date de création de la collection",
},
},
},
},
to_applicant_mails: [{ type: mailSchema, default: {} }],
to_cfa_mails: [{ type: mailSchema, default: {} }],
cle_ministere_educatif: {
type: String,
default: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,5 +497,5 @@ const mnaFormationSchema = new Schema<IFormationCatalogue>(
versionKey: false,
}
)

// @ts-ignore
export default model<IFormationCatalogue>("formationcatalogues", mnaFormationSchema)
20 changes: 12 additions & 8 deletions server/src/common/model/schema/geopoint/geoPoint.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import { Schema } from "../../../mongodb"
export const geoPointSchema = new Schema<{
type: string
coordinates: number[]
}>({
_id: false,
type: { type: String, default: "Point" },
coordinates: {
type: [Number],
default: [],
description: "Coordonnées [longitude,latitude] du point",
}>(
{
type: { type: String, default: "Point" },
coordinates: [
{
type: Number,
default: [],
description: "Coordonnées [longitude,latitude] du point",
},
],
},
})
{ _id: false }
)
14 changes: 8 additions & 6 deletions server/src/common/model/schema/jobs/jobs.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ export const jobsSchema = new Schema<IJob>(
type: String,
description: "Raison de la suppression de l'offre",
},
job_type: {
type: [String],
default: TRAINING_CONTRACT_TYPE.APPRENTISSAGE,
enum: Object.values(TRAINING_CONTRACT_TYPE),
description: "Type de contrat",
},
job_type: [
{
type: String,
default: TRAINING_CONTRACT_TYPE.APPRENTISSAGE,
enum: Object.values(TRAINING_CONTRACT_TYPE),
description: "Type de contrat",
},
],
is_multi_published: {
type: Boolean,
default: true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ILbaCompany } from "shared"
import { ILbaLegacyCompany } from "shared"

import { Schema, model } from "../../../mongodb"
import { lbaCompanySchema } from "../lbaCompany/lbaCompany.schema"

export const lbaCompanyLegacySchema = new Schema<Pick<ILbaCompany, "siret" | "email">>(
export const lbaCompanyLegacySchema = new Schema<ILbaLegacyCompany>(
{
siret: {
type: String,
Expand All @@ -21,4 +21,5 @@ export const lbaCompanyLegacySchema = new Schema<Pick<ILbaCompany, "siret" | "em
versionKey: false,
}
)
export default model<Pick<ILbaCompany, "siret" | "email">>("bonnesboiteslegacy", lbaCompanySchema)
// @ts-ignore
export default model<ILbaLegacyCompany>("bonnesboiteslegacy", lbaCompanySchema)
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { mongoosePagination, Pagination } from "../_shared/mongoose-paginate"
const { model } = mongoose

export const buildMongooseModel = <T>(schema: Schema<T>, tableName: string) => {
// @ts-ignore
schema.plugin(mongoosePagination)

return model<T, Pagination<T>>(tableName, schema)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EDiffusibleStatus } from "shared/constants/diffusibleStatus"
import { ISiretDiffusibleStatus } from "shared/models"

import { model, Schema } from "../../../mongodb"
Expand All @@ -13,7 +14,8 @@ export const siretDiffusibleStatusSchema = new Schema<ISiretDiffusibleStatus>(
},
status_diffusion: {
type: String,
default: "diffusible",
default: EDiffusibleStatus.DIFFUSIBLE,
enum: [Object.values(EDiffusibleStatus)[0], ...Object.values(EDiffusibleStatus).slice(1)],
description: "Le statut de diffusion : diffusible | partiellement_diffusible | non_diffusible",
},
created_at: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import { IUnsubscribedLbaCompany } from "shared"

import { model, Schema } from "../../../mongodb"
import { lbaCompanySchema } from "../lbaCompany/lbaCompany.schema"

const { siret, raison_sociale, enseigne, naf_code, naf_label, rome_codes, insee_city_code, zip_code, city, company_size, created_at, last_update_at } = lbaCompanySchema.obj
const unsubscribedLbaCompanySchema = new Schema<IUnsubscribedLbaCompany>(
{
siret,
raison_sociale,
enseigne,
naf_code,
naf_label,
rome_codes,
insee_city_code,
zip_code,
city,
company_size,
created_at,
last_update_at,
siret: String,
raison_sociale: String,
enseigne: String,
naf_code: String,
naf_label: String,
rome_codes: [String],
insee_city_code: String,
zip_code: String,
city: String,
company_size: String,
created_at: Date,
last_update_at: Date,
unsubscribe_date: {
type: Date,
default: Date.now,
Expand Down
Loading
Loading