0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-24 16:46:00 +01:00
mongodb/jstests/replsets/apply_ops_create_view.js
Matt Broadstone 771dabd098 SERVER-81339 Convert ReplSetTest and ShardingTest to modules (#26332)
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
2024-08-20 22:00:49 +00:00

19 lines
516 B
JavaScript

import {ReplSetTest} from "jstests/libs/replsettest.js";
const replTest = new ReplSetTest({nodes: 1});
replTest.startSet();
replTest.initiate();
const db = replTest.getPrimary().getDB('test');
assert.commandWorked(db.createCollection("bar"));
assert.commandWorked(db.bar.insert({a: 1, b: "hi"}));
const cmd = {
applyOps: [{op: "c", ns: db + ".$cmd", o: {create: "foo", viewOn: "bar"}}]
};
assert.commandWorked(db.runCommand(cmd), tojson(cmd));
assert.eq(db.foo.findOne({a: 1}).b, "hi");
replTest.stopSet();