Validation avec mongoose

Contrairement à mongodb qui ne permet pas de valider un schéma mongoose propose de nombreuses option de validation

lire : 🚀La validation Mongoose

import CVS

 Follow the Database Tools Installation Guide to install mongoimport.

😈 Run mongoimport from the system command line, not the mongo shell.


Example

🪛Lancez un terminal et ouvrir VisualStudio


>code .

🪛Créez un fichier File1.csv 
name,num,email
you,20240001,you@univ-evry.fr
me,20240002,me@univ-evry.fr

🪛Dans le terminal exécutez la commande

C:\Users\DD>mongoimport --type csv --headerline --db MyFirstDatabase --collection students --file File1.csv

🚀Verification



🪛Avec mongosh

> db.students.find()
[
  {
    _id: ObjectId("65469262c769f35c5f4be3fe"),
    name: 'you',
    num: 20240001,
    email: 'you@univ-evry.fr'
  },
  {
    _id: ObjectId("65469262c769f35c5f4be3ff"),
    name: 'me',
    num: 20240002,
    email: 'me@univ-evry.fr'
  }
]
>