mirror of
https://github.com/spacebarchat/server.git
synced 2026-05-10 19:17:03 +00:00
restructure to single project
This commit is contained in:
committed by
TheArcaneBrony
parent
5abd6bb7e0
commit
5e86d7ab9c
@@ -0,0 +1,28 @@
|
||||
const typeorm = require("typeorm");
|
||||
const Models = require("../dist/entities");
|
||||
const { PrimaryColumn } = require("typeorm");
|
||||
|
||||
function shouldIncludeEntity(name) {
|
||||
return ![Models.BaseClassWithoutId, PrimaryColumn, Models.BaseClass, Models.PrimaryGeneratedColumn]
|
||||
.map((x) => x?.name)
|
||||
.includes(name);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
console.log("starting");
|
||||
const db = new typeorm.DataSource({
|
||||
type: "sqlite",
|
||||
database: ":memory:",
|
||||
entities: Object.values(Models).filter((x) => x.constructor.name == "Function" && shouldIncludeEntity(x.name)),
|
||||
synchronize: true,
|
||||
});
|
||||
await db.initialize();
|
||||
console.log("Initialized database");
|
||||
|
||||
for (var i = 0; i < 100; i++) {
|
||||
await Models.User.register({ username: "User" + i });
|
||||
console.log("registered user " + i);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user