0

We have requirement to execute replaceOne operation with db.runCommand()

I checked list of commands from here, but i haven't found any command to replace one document.

Can someone please suggest us whether this is possible or not?

1

1 Answer 1

0

We can use update command to replace one document. Refer update for more details.

Sample replace command

{
    'update': 'collectionName',
    'updates': [
        {
            'q': {
                'age': '33'
            },
            'u': {
                'status': 'pass',
                'company': 'AK'
            }
        }
    ]
}

Refer update-with-a-replacement-document for more details

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.