2024-09-12 08:11:07 +00:00
|
|
|
import PropertyModal from "../models/property.js";
|
|
|
|
import UserModal from "../models/user.js";
|
|
|
|
import mongoose from "mongoose";
|
2024-09-15 08:58:40 +00:00
|
|
|
// import { v4 as uuidv4 } from "uuid";
|
2024-09-12 08:11:07 +00:00
|
|
|
|
|
|
|
export const createProperty = async (req, res) => {
|
2024-09-15 08:11:03 +00:00
|
|
|
const propertyData = req.body;
|
|
|
|
// console.log('Property received:', propertyData);
|
|
|
|
|
|
|
|
const newProperty = new PropertyModal({
|
|
|
|
...propertyData,
|
|
|
|
});
|
|
|
|
|
|
|
|
try {
|
|
|
|
await newProperty.save();
|
|
|
|
|
|
|
|
res.status(201).json(newProperty);
|
|
|
|
} catch (error) {
|
|
|
|
res.status(404).json({ message: "Something went wrong" });
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
2024-09-12 08:11:07 +00:00
|
|
|
|