Files
mongodump/test/sampledata.ts

50 lines
1007 B
TypeScript
Raw Normal View History

import * as smartdata from '@push.rocks/smartdata';
2022-06-05 21:04:16 +02:00
let db: smartdata.SmartdataDb;
export const stop = async () => {
await db.close();
}
export const generateTestData = async (mongoDescriptorArg: smartdata.IMongoDescriptor) => {
db = new smartdata.SmartdataDb(mongoDescriptorArg);
await db.init();
let counter = 0;
@smartdata.Collection(db)
class House extends smartdata.SmartDataDbDoc<House, House> {
@smartdata.unI()
id = `hello-${counter}`;
@smartdata.svDb()
data = {
'some' : {
2022-06-06 13:08:45 +02:00
'complex': 'structure',
more: 4
2022-06-05 21:04:16 +02:00
}
}
}
2022-06-06 13:04:30 +02:00
@smartdata.Collection(db)
class Truck extends smartdata.SmartDataDbDoc<Truck, Truck> {
@smartdata.unI()
id = `hello-${counter}`;
@smartdata.svDb()
data = {
'some' : {
2022-06-06 13:08:45 +02:00
'complex': 'structure',
more: 2
2022-06-06 13:04:30 +02:00
}
}
}
2022-06-05 21:04:16 +02:00
while (counter < 100) {
const house = new House();
await house.save();
2022-06-06 13:04:30 +02:00
const truck = new Truck();
await truck.save();
2022-06-05 21:04:16 +02:00
counter++;
}
}