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
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
*__note:__ the # at the end of lines are the pull request numbers on GitHub*

# Current

## Breaking Changes

* `KuzzleDataCollection` constructor signature has been changed from:
`KuzzleDataCollection(kuzzle, index, collection)`
to:
`KuzzleDataCollection(kuzzle, collection, index)`
This has been done to make it on par with the `Kuzzle.dataCollectionFactory` method

# 2.0.3

* https://github.com/kuzzleio/sdk-javascript/releases/tag/2.0.3
Expand Down
2 changes: 1 addition & 1 deletion src/kuzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ Kuzzle.prototype.dataCollectionFactory = function(collection, index) {
}

if (!this.collections[index][collection]) {
this.collections[index][collection] = new KuzzleDataCollection(this, index, collection);
this.collections[index][collection] = new KuzzleDataCollection(this, collection, index);
}

return this.collections[index][collection];
Expand Down
5 changes: 2 additions & 3 deletions src/kuzzleDataCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@ var
* A data collection is a set of data managed by Kuzzle. It acts like a data table for persistent documents,
* or like a room for pub/sub messages.
* @param {object} kuzzle - Kuzzle instance to inherit from
* @param {string} index - Index containing the data collection
* @param {string} collection - name of the data collection to handle
* @param {string} index - Index containing the data collection
* @constructor
*/
function KuzzleDataCollection(kuzzle, index, collection) {
function KuzzleDataCollection(kuzzle, collection, index) {
if (!index || !collection) {
throw new Error('The KuzzleDataCollection object constructor needs an index and a collection arguments');
}


Object.defineProperties(this, {
// read-only properties
collection: {
Expand Down
4 changes: 2 additions & 2 deletions test/kuzzleDataCollection/constructor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('KuzzleDataCollection constructor', function () {
c;

kuzzle.headers.some = 'headers';
c = new KuzzleDataCollection(kuzzle, index, collection);
c = new KuzzleDataCollection(kuzzle, collection, index);

// the collection "headers" should be a hard copy of the kuzzle ones
kuzzle.headers = { someother: 'headers' };
Expand All @@ -38,7 +38,7 @@ describe('KuzzleDataCollection constructor', function () {

Kuzzle.prototype.bluebird = bluebird;
kuzzle = new Kuzzle('foo');
dataCollection = new KuzzleDataCollection(kuzzle, 'foo', 'bar');
dataCollection = new KuzzleDataCollection(kuzzle, 'bar', 'foo');

should.exist(dataCollection.advancedSearchPromise);
should.exist(dataCollection.countPromise);
Expand Down
6 changes: 3 additions & 3 deletions test/kuzzleDataCollection/methods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ describe('KuzzleDataCollection methods', function () {

it('should send the right updateDocument query to Kuzzle', function (done) {
var
collection = new KuzzleDataCollection(kuzzle, expectedQuery.index, expectedQuery.collection),
collection = new KuzzleDataCollection(kuzzle, expectedQuery.collection, expectedQuery.index),
options = { queuable: false };
expectedQuery.options = options;

Expand All @@ -854,7 +854,7 @@ describe('KuzzleDataCollection methods', function () {
});

it('should handle arguments correctly', function () {
var collection = new KuzzleDataCollection(kuzzle, expectedQuery.index, expectedQuery.collection);
var collection = new KuzzleDataCollection(kuzzle, expectedQuery.collection, expectedQuery.index);

collection.updateDocument('foo');
should(emitted).be.true();
Expand All @@ -873,7 +873,7 @@ describe('KuzzleDataCollection methods', function () {
});

it('should call the callback with an error if one occurs', function (done) {
var collection = new KuzzleDataCollection(kuzzle, expectedQuery.index, expectedQuery.collection);
var collection = new KuzzleDataCollection(kuzzle, expectedQuery.collection, expectedQuery.index);
error = 'foobar';
this.timeout(50);

Expand Down