From 1cecd0202f6f891d5f76132ee17353c6e35d91a8 Mon Sep 17 00:00:00 2001 From: ilyayudovin Date: Thu, 11 Jun 2020 19:44:52 +0300 Subject: feat: add populateDb script --- populateDb.ts | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 populateDb.ts (limited to 'populateDb.ts') 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 -- cgit v1.2.3