-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into braydon/add-user-fields
- Loading branch information
Showing
8 changed files
with
95 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { faker } from "@faker-js/faker"; | ||
import { MongoClient } from "mongodb"; | ||
import { Entity } from "../models/entity.model"; | ||
|
||
function createRandomEntity(): Entity { | ||
return { | ||
id: faker.string.uuid(), | ||
stringField: faker.word.words({ count: { min: 1, max: 10 } }), | ||
intField: faker.number.int({ min: 2015, max: 2024 }), | ||
enumField: faker.helpers.arrayElement(["A", "B", "C", "D"]), | ||
stringArrayField: faker.helpers.arrayElements([ | ||
"One", | ||
"Two", | ||
"Three", | ||
"Four", | ||
"Five", | ||
]), | ||
boolField: faker.datatype.boolean(), | ||
fileName: faker.word.noun(), | ||
} as Entity; | ||
} | ||
|
||
async function seedEntities(): Promise<void> { | ||
const uri = process.env.MG_DATABASE_URL; | ||
if (uri === undefined) { | ||
return; | ||
} | ||
const client = new MongoClient(uri, { | ||
useNewUrlParser: true, | ||
// useUnifiedTopology: true, | ||
}); | ||
|
||
await client.connect(); | ||
const collection = client.db("test").collection("entities"); | ||
|
||
// collection.drop(); // drop() destroys all data in the collection, not sure if we want to every time | ||
|
||
const entityData: Entity[] = []; | ||
|
||
for (let i = 0; i < 10; i += 1) { | ||
const entity = createRandomEntity(); | ||
entityData.push(entity); | ||
} | ||
collection.insertMany(entityData); | ||
client.close(); | ||
} | ||
|
||
seedEntities(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -466,6 +466,11 @@ | |
minimatch "^3.0.4" | ||
strip-json-comments "^3.1.1" | ||
|
||
"@faker-js/faker@^8.4.1": | ||
version "8.4.1" | ||
resolved "https://registry.yarnpkg.com/@faker-js/faker/-/faker-8.4.1.tgz#5d5e8aee8fce48f5e189bf730ebd1f758f491451" | ||
integrity sha512-XQ3cU+Q8Uqmrbf2e0cIC/QN43sTBSC8KF12u29Mb47tWrt2hAgBXSgpZMj4Ao8Uk0iJcU99QsOCaIL8934obCg== | ||
|
||
"@firebase/[email protected]": | ||
version "0.6.1" | ||
resolved "https://registry.yarnpkg.com/@firebase/app-types/-/app-types-0.6.1.tgz#dcbd23030a71c0c74fc95d4a3f75ba81653850e9" | ||
|