Add Modify Delete Without Collection
Add Modify Delete Without Collection
if (!Table_Number) {
return res.status(400).json({ error: 'Table_Number is required.' });
}
try {
const newTable = new Single_Table({ Table_Number });
await newTable.save();
res.status(201).send('Table added successfully');
} catch (err) {
res.status(500).json({ error: 'Failed to add table', details:
err.message });
}
});
if (!mongoose.Types.ObjectId.isValid(id)) {
return res.status(400).json({ error: 'Invalid ID format.' });
}
const item = await Single_Table.findById(id);
if (!item) {
return res.status(404).json({ error: 'Table not found.' });
}
res.status(200).json(item);
} catch (error) {
res.status(500).json({ error: 'An error occurred while fetching the table.'
});
}
});
if (!result) {
return res.status(404).json({ message: 'Table not found' });
}
return res.status(200).json({ message: 'Table deleted successfully' });
} catch (error) {
res.status(500).send({ message: error.message });
}
});
if (!mongoose.Types.ObjectId.isValid(id)) {
return res.status(400).json({ error: 'Invalid ID.' });
}