31 lines
703 B
TypeScript
31 lines
703 B
TypeScript
import { Router } from "express";
|
|
import data from "../data/irth_unit_pirces.json" assert { type: "json" };
|
|
import Unit from "../models/Unit.js";
|
|
|
|
const router = Router();
|
|
|
|
router.get("/", async (req, res) => {
|
|
for (const item of data) {
|
|
const result = await Unit.findOneAndUpdate(
|
|
{ propertyName: item.unitName },
|
|
{ unitPrice: item.unitPrice },
|
|
{ new: true }
|
|
);
|
|
|
|
console.log("result", result);
|
|
}
|
|
|
|
// const file = fs.readFileSync(
|
|
// path.resolve("./src/data/irth_unit_pirces.json"),
|
|
// { encoding: "utf8" }
|
|
// );
|
|
|
|
// const data = JSON.parse(file);
|
|
|
|
res.json({ ok: 1 });
|
|
});
|
|
|
|
const updateApartmentsRoute = router;
|
|
|
|
export default updateApartmentsRoute;
|