Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ describe('CliServiceProvider', () => {
it('executes the command', async() => {
const result = await serviceProvider.createCollection('db1', 'newcoll', {});
expect(result).to.deep.equal({ ok: 1 });
expect(dbStub.createCollection).to.have.been.calledOnceWith('newcoll', {});
expect(dbStub.createCollection).to.have.been.calledOnceWith('newcoll', DEFAULT_BASE_OPTS);
expect(clientStub.db).to.have.been.calledOnceWith('db1');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,7 @@ class CliServiceProvider extends ServiceProviderCore implements ServiceProvider
options: CreateCollectionOptions = {},
dbOptions?: DbOptions
): Promise<{ ok: number }> {
options = { ...this.baseCmdOptions, ...options };
await this.db(dbName, dbOptions).createCollection(
collName, options
);
Expand Down
28 changes: 28 additions & 0 deletions packages/shell-api/src/integration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,34 @@ describe('Shell API (integration)', function() {
}
]);
});
context('features only available on mongodb 4.4+', () => {
skipIfServerVersion(testServer, '< 4.4');
it('creates a view that potentially contains JS functions in its pipeline', async() => {
const pipeline = (body: any) => [{
'$set': {
'name_md5': { '$function': { 'lang': 'js', 'args': ['$name'], 'body': body } }
}
}];
const fn = compileExpr `function (val) {
return hex_md5(val);
}`;
expect(
await database.createView(
'view',
'source',
pipeline(fn)
)
).to.deep.equal({ ok: 1 });
const views = await serviceProvider.find(dbName, 'system.views', {}).toArray();
expect(JSON.parse(JSON.stringify(views))).to.deep.equal([
{
_id: `${dbName}.view`,
viewOn: 'source',
pipeline: pipeline({ code: fn.toString() })
}
]);
});
});
});
});

Expand Down