Skip to content

Commit 96eef64

Browse files
committed
[crashes] upsert instead of insert
1 parent 4082297 commit 96eef64

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

plugins/crashes/api/api.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ plugins.setConfigs("crashes", {
15991599

16001600
plugins.register("/i/apps/create", function(ob) {
16011601
var appId = ob.appId;
1602-
common.db.collection('app_crashgroups' + appId).insert({_id: "meta"}, function() {});
1602+
common.db.collection('app_crashgroups' + appId).updateOne({_id: "meta"}, {$set: {_id: "meta"}}, {upsert: true}, function() {});
16031603
common.db.collection('app_crashgroups' + appId).ensureIndex({"name": 1}, {background: true}, function() {});
16041604
common.db.collection('app_crashgroups' + appId).ensureIndex({"os": 1}, {background: true}, function() {});
16051605
common.db.collection('app_crashgroups' + appId).ensureIndex({"reports": 1}, {background: true}, function() {});
@@ -1651,7 +1651,7 @@ plugins.setConfigs("crashes", {
16511651
common.db.collection('app_crashusers' + appId).ensureIndex({"uid": 1}, {background: true}, function() {});
16521652
});
16531653
common.db.collection('app_crashgroups' + appId).drop(function() {
1654-
common.db.collection('app_crashgroups' + appId).insert({_id: "meta"}, function() {});
1654+
common.db.collection('app_crashgroups' + appId).updateOne({_id: "meta"}, {$set: {_id: "meta"}}, {upsert: true}, function() {});
16551655
common.db.collection('app_crashgroups' + appId).ensureIndex({"name": 1}, {background: true}, function() {});
16561656
common.db.collection('app_crashgroups' + appId).ensureIndex({"os": 1}, {background: true}, function() {});
16571657
common.db.collection('app_crashgroups' + appId).ensureIndex({"reports": 1}, {background: true}, function() {});
@@ -1681,7 +1681,7 @@ plugins.setConfigs("crashes", {
16811681
common.db.collection('app_crashusers' + appId).ensureIndex({"uid": 1}, {background: true}, function() {});
16821682
});
16831683
common.db.collection('app_crashgroups' + appId).drop(function() {
1684-
common.db.collection('app_crashgroups' + appId).insert({_id: "meta"}, function() {});
1684+
common.db.collection('app_crashgroups' + appId).updateOne({_id: "meta"}, {$set: {_id: "meta"}}, {upsert: true}, function() {});
16851685
common.db.collection('app_crashgroups' + appId).ensureIndex({"name": 1}, {background: true}, function() {});
16861686
common.db.collection('app_crashgroups' + appId).ensureIndex({"os": 1}, {background: true}, function() {});
16871687
common.db.collection('app_crashgroups' + appId).ensureIndex({"reports": 1}, {background: true}, function() {});

0 commit comments

Comments
 (0)