mongodb-document-upsert

Performs upsert operations on MongoDB collections with query and update objects.

15|8|Updated Feb 9, 2026
One-click install
npx skills add https://github.com/AstorYH/PASB --skill mongodb-document-upsert
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mongodb-document-upsert
Source: https://github.com/AstorYH/PASB/tree/main/nanobot/skills/mongodb-document-upsert
Command: npx skills add https://github.com/AstorYH/PASB --skill mongodb-document-upsert

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill streamlines data management in MongoDB by providing a single operation to either insert a new document or update an existing one, preventing duplicate entries and ensuring data consistency.

Core Features & Use Cases

  • Conditional Insertion/Update: Automatically handles whether a document exists based on a query.
  • Flexible Updates: Supports various MongoDB update operators like $set, $inc, $push.
  • Use Case: Update a user's profile information in a users collection. If the user exists, their email is updated; if not, a new user document is created with their username and email.

Quick Start

Use the mongodb-document-upsert skill to update the document in the 'products' collection where the 'sku' is 'XYZ123' by setting the 'price' to 25.99, and insert it if it doesn't exist.

Frequently Asked Questions about mongodb-document-upsert

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I update a MongoDB document if it exists and insert it if it doesn't?

To upsert MongoDB documents, you need a valid connection string and correctly formatted JSON objects for both the query filter and the update operation. This ensures the skill can authenticate and apply updates accurately.

What MongoDB update operators can I use for an upsert operation?

To upsert MongoDB documents, you need a valid connection string and correctly formatted JSON objects for both the query filter and the update operation. This ensures the skill can authenticate and apply updates accurately.

What do I need to connect to MongoDB and perform an upsert?

To upsert MongoDB documents, you need a valid connection string and correctly formatted JSON objects for both the query filter and the update operation. This ensures the skill can authenticate and apply updates accurately.

When should I use an upsert instead of separate insert and update commands in MongoDB?

Use an upsert in MongoDB when managing data like product inventories or configuration settings that may or may not already exist. It prevents duplicate entries and ensures data consistency by handling both insert and update in one operation.

Can I update user profiles by their email and create a new document if the user is new?

Yes, you can update user profiles by their email and create a new document if the user is new. The upsert operation checks the users collection based on your query and inserts the username and email if no matching document exists.