Latest Project, Trash and setting API and sockets along with the Model clearance
This commit is contained in:
@@ -1,43 +1,46 @@
|
||||
import { Request, Response } from "express";
|
||||
import userModel from "../../../shared/model/user-Model.ts";
|
||||
|
||||
export class Share {
|
||||
static async shareUser(req: Request, res: Response) {
|
||||
try {
|
||||
const { email, isShare, organization } = req.body;
|
||||
|
||||
export class share {
|
||||
static async shareUser(req: Request, res: Response) {
|
||||
try {
|
||||
const { email, isShare, organization } = req.body
|
||||
|
||||
const findValue = await userModel(organization).findOneAndUpdate(
|
||||
{ email: email },
|
||||
{ isShare: isShare },
|
||||
{ new: true }
|
||||
);
|
||||
|
||||
const findValue = await userModel(organization).findOneAndUpdate({email:email},{isShare:isShare},{new:true})
|
||||
|
||||
res.status(201).json({message:"scene shared successfully",data:findValue});
|
||||
if (!findValue) {
|
||||
res.status(404).json({message:"Not found"})
|
||||
}
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error('Error creating Share:', error);
|
||||
res.status(500).json({message:"Failed to create Share"});
|
||||
}
|
||||
res
|
||||
.status(201)
|
||||
.json({ message: "scene shared successfully", data: findValue });
|
||||
if (!findValue) {
|
||||
res.status(404).json({ message: "Not found" });
|
||||
}
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error("Error creating Share:", error);
|
||||
res.status(500).json({ message: "Failed to create Share" });
|
||||
}
|
||||
|
||||
static async findshareUser(req: Request, res: Response) {
|
||||
try {
|
||||
const organization = req.query.organization as string;
|
||||
|
||||
|
||||
const findValue = await userModel(organization).find({}).select("isShare email userName -_id")
|
||||
// console.log('findValue: ', findValue);
|
||||
|
||||
res.status(201).json({message:"scene shared datas",data:findValue});
|
||||
if (!findValue) {
|
||||
res.status(404).json({message:"Not found"})
|
||||
}
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error('Error Share:', error);
|
||||
res.status(500).json({message:"Failed to Share datas "});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static async findshareUser(req: Request, res: Response) {
|
||||
try {
|
||||
const organization = req.query.organization as string;
|
||||
|
||||
const findValue = await userModel(organization)
|
||||
.find({})
|
||||
.select("isShare email userName -_id");
|
||||
|
||||
res.status(201).json({ message: "scene shared datas", data: findValue });
|
||||
if (!findValue) {
|
||||
res.status(404).json({ message: "Not found" });
|
||||
}
|
||||
// Send response with the created document
|
||||
} catch (error) {
|
||||
console.error("Error Share:", error);
|
||||
res.status(500).json({ message: "Failed to Share datas " });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user