Skip to content

Commit

Permalink
removed the dataCollection.putMapping method
Browse files Browse the repository at this point in the history
  • Loading branch information
scottinet committed Jan 27, 2016
1 parent 1018cbe commit 4f0efd0
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 117 deletions.
23 changes: 0 additions & 23 deletions dist/kuzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -1760,29 +1760,6 @@ KuzzleDataCollection.prototype.publishMessage = function (document, options) {
return this;
};

/**
* Applies a new mapping to the data collection.
* Note that you cannot delete an existing mapping, you can only add or update one.
*
* @param {object} mapping - mapping to apply
* @param {object} [options] - optional arguments
* @param {responseCallback} [cb] - Returns an instantiated KuzzleDataMapping object
* @returns {*} this
*/
KuzzleDataCollection.prototype.putMapping = function (mapping, options, cb) {
var dataMapping;

if (!cb && typeof options === 'function') {
cb = options;
options = null;
}

dataMapping = new KuzzleDataMapping(this, mapping);
dataMapping.apply(options, cb);

return this;
};

/**
* Replace an existing document with a new one.
*
Expand Down
4 changes: 2 additions & 2 deletions dist/kuzzle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/kuzzle.min.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kuzzle-sdk",
"version": "1.3.7",
"version": "1.3.8",
"description": "Official Javascript SDK for Kuzzle",
"author": "The Kuzzle Team <support@kuzzle.io>",
"repository": {
Expand Down
23 changes: 0 additions & 23 deletions src/kuzzleDataCollection.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,29 +430,6 @@ KuzzleDataCollection.prototype.publishMessage = function (document, options) {
return this;
};

/**
* Applies a new mapping to the data collection.
* Note that you cannot delete an existing mapping, you can only add or update one.
*
* @param {object} mapping - mapping to apply
* @param {object} [options] - optional arguments
* @param {responseCallback} [cb] - Returns an instantiated KuzzleDataMapping object
* @returns {*} this
*/
KuzzleDataCollection.prototype.putMapping = function (mapping, options, cb) {
var dataMapping;

if (!cb && typeof options === 'function') {
cb = options;
options = null;
}

dataMapping = new KuzzleDataMapping(this, mapping);
dataMapping.apply(options, cb);

return this;
};

/**
* Replace an existing document with a new one.
*
Expand Down
67 changes: 0 additions & 67 deletions test/kuzzleDataCollection/methods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -696,73 +696,6 @@ describe('KuzzleDataCollection methods', function () {
});
});

describe('#putMapping', function () {
var
KuzzleDataCollectionProxyquired,
collection;

beforeEach(function () {
expectedQuery = {
index: 'bar',
collection: 'foo',
action: 'putMapping',
controller: 'admin',
body: {}
};

KuzzleDataCollectionProxyquired = proxyquire('../../src/kuzzleDataCollection', {
'./kuzzleDataMapping': function (c, m) {
var dm = new KuzzleDataMapping(c, m);

dm.refresh = function (options, cb) {
cb(null, result);
};
return dm;
}
});

kuzzle = new Kuzzle('foo', {defaultIndex: 'bar'});
collection = new KuzzleDataCollectionProxyquired(kuzzle, expectedQuery.index, expectedQuery.collection);
kuzzle.query = queryStub;
emitted = false;
result = { result: {_source: { properties: {}}}};
error = null;
});

it('should instantiate a new KuzzleDataMapping object', function (done) {
var
options = { queuable: false };

expectedQuery.options = options;

should(collection.putMapping(result.result, options, function (err, res) {
should(err).be.null();
done();
})).be.exactly(collection);
should(emitted).be.true();
});

it('should handle the callback argument correctly', function () {
collection.putMapping(result.result, function () {});
should(emitted).be.true();

emitted = false;
collection.putMapping(result.result, {}, function () {});
should(emitted).be.true();
});

it('should call the callback with an error if one occurs', function (done) {
error = 'foobar';
this.timeout(50);

collection.putMapping({}, function (err, res) {
should(err).be.exactly('foobar');
should(res).be.undefined();
done();
});
});
});

describe('#replaceDocument', function () {
beforeEach(function () {
kuzzle = new Kuzzle('foo', {defaultIndex: 'bar'});
Expand Down

0 comments on commit 4f0efd0

Please sign in to comment.