
Security News
MCP Community Begins Work on Official MCP Metaregistry
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
soft-deleting-mongoose
Advanced tools
This is a simple, easy-to-understand soft deleting package for MongoDB using Mongoose ODM.
This is a simple, easy-to-understand soft deleting package for MongoDB using Mongoose ODM. This package gives you all functionality to soft delete any Mongodb document. So let's start soft deleting...
npm install soft-deleting-mongoose
Firstly import MongooseSchema and create a schema.
const userSchema = new MongooseSchema({
name: {
type: String,
required: true
},
email: {
type: String,
required: true,
},
role: {
type: String,
default: "user"
},
password: String
});
const User = mongoose.model('User', userSchema);
app.delete("/user/:_id", async (req, res, next) => {
try {
const _id = req.params._id;
const user = await User.softDeleteById(_id);
return res.status(200).json({ success: true, data: user });
} catch (error) {
next(error);
}
});
In the above, I have declared a model named User. Now I am giving examples using the User model.
User.find({}).notDeleted();
User.find({}).onlyDeleted();
User.find({}).withDeleted();
In the above, I have declared a model named User. Now I am giving examples using the User model.
User.softDelete({ role: "user" });
const _id = "6405d153a208cbfd7b88b0c5";
User.softDeleteById(_id);
const _id = "6405d153a208cbfd7b88b0c5";
User.restoreById(_id);
const _id = "6405d153a208cbfd7b88b0c5";
User.restoreById(_id);
User.restoreAll();
const _id = "6405d153a208cbfd7b88b0c5";
User.forceDeleteById(_id);
User.forceDeleteById({ role: "sub-admin" });
const User = mongoose.model<IUserDoc, Model<IUserDoc, IQueryHelpers<IUserDoc>>>('User', userSchema);
Heder, IUserDoc is the interface of user, Model is imported from mongoose, and IQueryHelpers is imported from soft-deleting-mongoose package.
FAQs
This is a simple, easy-to-understand soft deleting package for MongoDB using Mongoose ODM.
The npm package soft-deleting-mongoose receives a total of 1 weekly downloads. As such, soft-deleting-mongoose popularity was classified as not popular.
We found that soft-deleting-mongoose demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.
Research
Security News
Socket uncovers an npm Trojan stealing crypto wallets and BullX credentials via obfuscated code and Telegram exfiltration.
Research
Security News
Malicious npm packages posing as developer tools target macOS Cursor IDE users, stealing credentials and modifying files to gain persistent backdoor access.