diff options
Diffstat (limited to 'populateDb.ts')
-rw-r--r-- | populateDb.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/populateDb.ts b/populateDb.ts new file mode 100644 index 0000000..1442350 --- /dev/null +++ b/populateDb.ts @@ -0,0 +1,28 @@ +import mongoose from 'mongoose'; +import app from './app'; + +mongoose.connect('mongodb://localhost:27017/which', { useNewUrlParser: true }); + +import UserModel from './models/users/user.model'; +(async () => { + const users = [ + { name: "Emma" }, + { name: "Elise" }, + { name: "Jack" }, + { name: "Oliver" }, + { name: "Jamie" }, + { name: "Aidan" }, + { name: "Jordan" }, + { name: "Erin" }, + { name: "William" }, + { name: "Ethan" }, + ]; + try { + for (const user of users) { + await UserModel.create(user); + } + } catch (e) { + console.error(e); + } + mongoose.disconnect(); +})();
\ No newline at end of file |