|
|
@ -1,10 +1,10 @@ |
|
|
|
import { faker } from '@faker-js/faker'; |
|
|
|
import { faker } from '@faker-js/faker'; |
|
|
|
import { max, min } from 'class-validator'; |
|
|
|
|
|
|
|
import { AppDataSource } from 'src/data-source'; |
|
|
|
import { AppDataSource } from 'src/data-source'; |
|
|
|
import { SensorData } from 'src/sensors/entities/sensor-data.entity'; |
|
|
|
import { SensorData } from 'src/sensors/entities/sensor-data.entity'; |
|
|
|
import { SensorGroup } from 'src/sensors/entities/sensor-group.entity'; |
|
|
|
import { SensorGroup } from 'src/sensors/entities/sensor-group.entity'; |
|
|
|
import { Sensor } from 'src/sensors/entities/sensor.entity'; |
|
|
|
import { Sensor } from 'src/sensors/entities/sensor.entity'; |
|
|
|
import { User } from 'src/users/entities/user.entity'; |
|
|
|
import { User } from 'src/users/entities/user.entity'; |
|
|
|
|
|
|
|
import * as bcrypt from 'bcryptjs'; |
|
|
|
|
|
|
|
|
|
|
|
async function run() { |
|
|
|
async function run() { |
|
|
|
await AppDataSource.initialize(); |
|
|
|
await AppDataSource.initialize(); |
|
|
@ -19,16 +19,16 @@ async function run() { |
|
|
|
const sensorRepo = AppDataSource.getRepository(Sensor); |
|
|
|
const sensorRepo = AppDataSource.getRepository(Sensor); |
|
|
|
const dataRepo = AppDataSource.getRepository(SensorData); |
|
|
|
const dataRepo = AppDataSource.getRepository(SensorData); |
|
|
|
|
|
|
|
|
|
|
|
// for (let i = 0; i < 2; i++) {
|
|
|
|
for (let i = 0; i < 2; i++) { |
|
|
|
// const name = `seed_user_${faker.finance.amount({ min: 0, max: 100, dec: 0 })}`;
|
|
|
|
const name = `seed_user_${faker.finance.amount({ min: 0, max: 100, dec: 0 })}`; |
|
|
|
// const user = userRepo.create({
|
|
|
|
const user = userRepo.create({ |
|
|
|
// name,
|
|
|
|
name, |
|
|
|
// email: `${name}@email.com`,
|
|
|
|
email: `${name}@email.com`, |
|
|
|
// password: '1234',
|
|
|
|
password: await bcrypt.hash('1234', 10), |
|
|
|
// });
|
|
|
|
}); |
|
|
|
// await userRepo.save(user);
|
|
|
|
await userRepo.save(user); |
|
|
|
// console.log(`✅ Created User ${user.name}`);
|
|
|
|
console.log(`✅ Created User ${user.name}`); |
|
|
|
// }
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const users = await userRepo.find({ take: 2, order: { createdAt: 'DESC' } }); |
|
|
|
const users = await userRepo.find({ take: 2, order: { createdAt: 'DESC' } }); |
|
|
|
if (!users.length) { |
|
|
|
if (!users.length) { |
|
|
|