mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-24 16:46:00 +01:00
771dabd098
GitOrigin-RevId: 744aa110a53786b23c62ff53f87a1418b5991e8d
19 lines
516 B
JavaScript
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();
|