mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
improve spacing
This commit is contained in:
@@ -42,48 +42,49 @@
|
||||
var uuid='30fb2640-7121-4968-ace5-f385e60ea6c5';
|
||||
|
||||
db.users.aggregate([
|
||||
{$match: {'_id': uuid} },
|
||||
{$project: {
|
||||
'_id':0, 'todos':1
|
||||
}},
|
||||
{$unwind: '$todos'},
|
||||
{$group: {
|
||||
_id: { taskid: '$todos.id' },
|
||||
count: { $sum: 1 }
|
||||
}},
|
||||
{ $match: {
|
||||
count: { $gt: 1 }
|
||||
}},
|
||||
{ $project: {
|
||||
'_id.taskid':1,
|
||||
}},
|
||||
{$group: {
|
||||
_id: { taskid: '$todos.id' },
|
||||
troublesomeIds: { $addToSet: "$_id.taskid" },
|
||||
}},
|
||||
{ $project: {
|
||||
'_id':0,
|
||||
troublesomeIds:1,
|
||||
}},
|
||||
{$match: {
|
||||
'_id': uuid
|
||||
}},
|
||||
{$project: {
|
||||
'_id':0, 'todos':1
|
||||
}},
|
||||
{$unwind: '$todos'},
|
||||
{$group: {
|
||||
_id: { taskid: '$todos.id' },
|
||||
count: { $sum: 1 }
|
||||
}},
|
||||
{$match: {
|
||||
count: { $gt: 1 }
|
||||
}},
|
||||
{$project: {
|
||||
'_id.taskid':1,
|
||||
}},
|
||||
{$group: {
|
||||
_id: { taskid: '$todos.id' },
|
||||
troublesomeIds: { $addToSet: "$_id.taskid" },
|
||||
}},
|
||||
{$project: {
|
||||
'_id':0,
|
||||
troublesomeIds:1,
|
||||
}},
|
||||
]).forEach(
|
||||
function(data) {
|
||||
// print( "\n" ); printjson(data);
|
||||
data.troublesomeIds.forEach( function(taskid) {
|
||||
print('non-unique task: ' + taskid);
|
||||
db.users.update({
|
||||
'_id': uuid,
|
||||
'todos': { $elemMatch: { id: taskid } }
|
||||
},
|
||||
{ $set: { "todos.$.id" : 'de666' }
|
||||
});
|
||||
});
|
||||
}
|
||||
function(data) {
|
||||
// print( "\n" ); printjson(data);
|
||||
data.troublesomeIds.forEach( function(taskid) {
|
||||
print('non-unique task: ' + taskid);
|
||||
db.users.update({
|
||||
'_id': uuid,
|
||||
'todos': { $elemMatch: { id: taskid } }
|
||||
},{
|
||||
$set: { "todos.$.id" : 'de666' }
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
db.users.update(
|
||||
{'_id': uuid},
|
||||
{ $pull: { todos: { id: 'de666' } } },
|
||||
{ multi: false }
|
||||
{'_id': uuid},
|
||||
{$pull: { todos: { id: 'de666' } } },
|
||||
{multi: false }
|
||||
);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user