0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 01:21:03 +01:00
mongodb/jstests/core/geo_update1.js
Jack Mulrow 00d92ece19 SERVER-31194 Add jscore tags for retryable_writes_jscore_stepdown_passthrough.yml suite
The actual suite will come in a follow-up commit.
2017-12-07 14:36:15 -05:00

38 lines
800 B
JavaScript

// @tags: [requires_non_retryable_writes]
t = db.geo_update1;
t.drop();
for (var x = 0; x < 10; x++) {
for (var y = 0; y < 10; y++) {
t.insert({"loc": [x, y], x: x, y: y, z: 1});
}
}
t.ensureIndex({loc: "2d"});
function p() {
print("--------------");
for (var y = 0; y < 10; y++) {
var c = t.find({y: y}).sort({x: 1});
var s = "";
while (c.hasNext())
s += c.next().z + " ";
print(s);
}
print("--------------");
}
p();
var res = t.update({loc: {$within: {$center: [[5, 5], 2]}}}, {$inc: {z: 1}}, false, true);
assert.writeOK(res);
p();
assert.writeOK(t.update({}, {'$inc': {'z': 1}}, false, true));
p();
res = t.update({loc: {$within: {$center: [[5, 5], 2]}}}, {$inc: {z: 1}}, false, true);
assert.writeOK(res);
p();