Created
November 4, 2017 13:57
-
-
Save isa424/ba932c276a88bc9d6d6f367e34bbc226 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const conn = new Mongo("127.0.0.1:27017"); | |
| const db = conn.getDB("cubicl"); | |
| db.auth("app", "12345678"); | |
| var todos = db.todos.find({"category": {$ne: null}}); | |
| todos.forEach(function(todo) { | |
| var category = todo.category; | |
| var exists = db.todo_categories.find({_id: category}).count(); | |
| if (!exists) { | |
| db.todos.updateOne({_id: todo._id}, {$set: {category: null}}); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment