50 lines
1006 B
TypeScript
50 lines
1006 B
TypeScript
import * as smartdata from '@pushrocks/smartdata';
|
|
|
|
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' : {
|
|
'complex': 'structure',
|
|
more: 4
|
|
}
|
|
}
|
|
}
|
|
|
|
@smartdata.Collection(db)
|
|
class Truck extends smartdata.SmartDataDbDoc<Truck, Truck> {
|
|
@smartdata.unI()
|
|
id = `hello-${counter}`;
|
|
|
|
@smartdata.svDb()
|
|
data = {
|
|
'some' : {
|
|
'complex': 'structure',
|
|
more: 2
|
|
}
|
|
}
|
|
}
|
|
|
|
while (counter < 100) {
|
|
const house = new House();
|
|
await house.save();
|
|
const truck = new Truck();
|
|
await truck.save();
|
|
counter++;
|
|
}
|
|
}
|