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 @@ -394,4 +394,25 @@ describe('DefaultCrudRepository', () => {
const ok = await repo.exists(note1.id);
expect(ok).to.be.true();
});

it('implements Repository.execute()', async () => {
// Dummy implementation for execute() in datasource
ds.execute = (command, parameters, options) => {
return Promise.resolve({command, parameters, options});
};
const repo = new DefaultCrudRepository(Note, ds);
const result = await repo.execute('query', ['arg']);
expect(result).to.eql({
command: 'query',
parameters: ['arg'],
options: undefined,
});
});

it(`throws error when execute() not implemented by ds connector`, async () => {
const repo = new DefaultCrudRepository(Note, ds);
await expect(repo.execute('query', [])).to.be.rejectedWith(
'execute() must be implemented by the connector',
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,10 @@ export class DefaultCrudRepository<T extends Entity, ID>

async execute(
command: Command,
// tslint:disable:no-any
parameters: NamedParameters | PositionalParameters,
options?: Options,
): Promise<AnyObject> {
/* istanbul ignore next */
throw new Error('Not implemented');
return ensurePromise(this.dataSource.execute(command, parameters, options));
}

protected toEntity(model: juggler.PersistedModel): T {
Expand Down