make it betters
This commit is contained in:
parent
7157a7ce8c
commit
bd80a98f07
@ -1,8 +1,17 @@
|
||||
import directoryModel from "../models/directoryModel.js";
|
||||
import cloudinary from "cloudinary";
|
||||
export const createDirectory = async (req, res) => {
|
||||
|
||||
try {
|
||||
const { name,
|
||||
const files = req.files.image;
|
||||
console.log(req.body)
|
||||
console.log(files)
|
||||
const myCloud = await cloudinary.uploader.upload(files.tempFilePath, {
|
||||
folder: "cmp/image",
|
||||
},
|
||||
function (error, result) { (result, error) });
|
||||
const {
|
||||
name,
|
||||
phone,
|
||||
email,
|
||||
Bname,
|
||||
@ -17,7 +26,7 @@ export const createDirectory = async (req, res) => {
|
||||
FacebookUrl,
|
||||
InstagramUrl,
|
||||
} = req.body;
|
||||
// console.log(name)
|
||||
// console.log(req.body)
|
||||
const data = await directoryModel.create({
|
||||
|
||||
name,
|
||||
@ -34,6 +43,10 @@ export const createDirectory = async (req, res) => {
|
||||
LinkedinUrl,
|
||||
FacebookUrl,
|
||||
InstagramUrl,
|
||||
image: {
|
||||
public_id: myCloud.public_id,
|
||||
url: myCloud.secure_url,
|
||||
},
|
||||
|
||||
});
|
||||
res.status(201).json({
|
||||
|
@ -12,7 +12,18 @@ const directorySchema = new mongoose.Schema(
|
||||
email: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true
|
||||
// unique: true
|
||||
},
|
||||
image:
|
||||
{
|
||||
public_id: {
|
||||
type: String,
|
||||
// required: true,
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
// required: true,
|
||||
},
|
||||
},
|
||||
Building_Name: {
|
||||
type: String,
|
||||
|
BIN
tmp/tmp-1-1654775218060
Normal file
BIN
tmp/tmp-1-1654775218060
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-1-1654775339604
Normal file
BIN
tmp/tmp-1-1654775339604
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
BIN
tmp/tmp-2-1654775431357
Normal file
BIN
tmp/tmp-2-1654775431357
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 MiB |
Loading…
Reference in New Issue
Block a user