make it betters
This commit is contained in:
parent
7157a7ce8c
commit
bd80a98f07
@ -1,8 +1,17 @@
|
|||||||
import directoryModel from "../models/directoryModel.js";
|
import directoryModel from "../models/directoryModel.js";
|
||||||
|
import cloudinary from "cloudinary";
|
||||||
export const createDirectory = async (req, res) => {
|
export const createDirectory = async (req, res) => {
|
||||||
|
|
||||||
try {
|
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,
|
phone,
|
||||||
email,
|
email,
|
||||||
Bname,
|
Bname,
|
||||||
@ -17,7 +26,7 @@ export const createDirectory = async (req, res) => {
|
|||||||
FacebookUrl,
|
FacebookUrl,
|
||||||
InstagramUrl,
|
InstagramUrl,
|
||||||
} = req.body;
|
} = req.body;
|
||||||
// console.log(name)
|
// console.log(req.body)
|
||||||
const data = await directoryModel.create({
|
const data = await directoryModel.create({
|
||||||
|
|
||||||
name,
|
name,
|
||||||
@ -34,6 +43,10 @@ export const createDirectory = async (req, res) => {
|
|||||||
LinkedinUrl,
|
LinkedinUrl,
|
||||||
FacebookUrl,
|
FacebookUrl,
|
||||||
InstagramUrl,
|
InstagramUrl,
|
||||||
|
image: {
|
||||||
|
public_id: myCloud.public_id,
|
||||||
|
url: myCloud.secure_url,
|
||||||
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
res.status(201).json({
|
res.status(201).json({
|
||||||
|
@ -12,7 +12,18 @@ const directorySchema = new mongoose.Schema(
|
|||||||
email: {
|
email: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: true,
|
||||||
unique: true
|
// unique: true
|
||||||
|
},
|
||||||
|
image:
|
||||||
|
{
|
||||||
|
public_id: {
|
||||||
|
type: String,
|
||||||
|
// required: true,
|
||||||
|
},
|
||||||
|
url: {
|
||||||
|
type: String,
|
||||||
|
// required: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Building_Name: {
|
Building_Name: {
|
||||||
type: String,
|
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