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: 5 additions & 5 deletions src/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ Collection.prototype.create = function (options, cb) {
* Create a new document in Kuzzle.
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
* - ifExist (string, allowed values: "error" (default), "replace"):
* If the same document already exists:
Expand Down Expand Up @@ -209,7 +209,7 @@ Collection.prototype.createDocument = function (id, document, options, cb) {
* That means that a document that was just been created won’t be returned by this function
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {string|object} arg - Either a document ID (will delete only this particular document), or a set of filters
Expand Down Expand Up @@ -361,7 +361,7 @@ Collection.prototype.getMapping = function (options, cb) {
* Publish a realtime message
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {object} document - either a Document instance or a JSON object
Expand All @@ -388,7 +388,7 @@ Collection.prototype.publishMessage = function (document, options, cb) {
* Replace an existing document with a new one.
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {string} documentId - Unique document identifier of the document to replace
Expand Down Expand Up @@ -612,7 +612,7 @@ Collection.prototype.truncate = function (options, cb) {
* Update parts of a document
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {string} documentId - Unique document identifier of the document to update
Expand Down
6 changes: 3 additions & 3 deletions src/Document.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Document.prototype.toString = function () {
* Deletes this document in Kuzzle.
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {object} [options] - Optional parameters
Expand Down Expand Up @@ -194,7 +194,7 @@ Document.prototype.refresh = function (options, cb) {
* of this object.
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {object} [options] - Optional parameters
Expand Down Expand Up @@ -231,7 +231,7 @@ Document.prototype.save = function (options, cb) {
* Sends the content of this document as a realtime message.
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {object} [options] - Optional parameters
Expand Down
20 changes: 10 additions & 10 deletions src/Kuzzle.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function Kuzzle (host, options, cb) {
enumerable: true,
writable: true
},
metadata: {
volatile: {
value: {},
enumerable: true,
writable: true
Expand Down Expand Up @@ -1252,7 +1252,7 @@ Kuzzle.prototype.now = function (options, cb) {
* Base method used to send read queries to Kuzzle
*
* Takes an optional argument object with the following properties:
* - metadata (object, default: null):
* - volatile (object, default: null):
* Additional information passed to notifications to other users
*
* @param {object} queryArgs - Query configuration
Expand All @@ -1266,7 +1266,7 @@ Kuzzle.prototype.query = function (queryArgs, query, options, cb) {
object = {
action: queryArgs.action,
controller: queryArgs.controller,
metadata: this.metadata
volatile: this.volatile
},
self = this;

Expand Down Expand Up @@ -1302,9 +1302,9 @@ Kuzzle.prototype.query = function (queryArgs, query, options, cb) {
object.scrollId = options.scrollId;
}

if (options.metadata) {
Object.keys(options.metadata).forEach(function (meta) {
object.metadata[meta] = options.metadata[meta];
if (options.volatile) {
Object.keys(options.volatile).forEach(function (meta) {
object.volatile[meta] = options.volatile[meta];
});
}
}
Expand All @@ -1313,14 +1313,14 @@ Kuzzle.prototype.query = function (queryArgs, query, options, cb) {
throw new Error('Invalid query parameter: ' + query);
}

if (query.metadata) {
Object.keys(query.metadata).forEach(function (meta) {
object.metadata[meta] = query.metadata[meta];
if (query.volatile) {
Object.keys(query.volatile).forEach(function (meta) {
object.volatile[meta] = query.volatile[meta];
});
}

for (attr in query) {
if (attr !== 'metadata' && query.hasOwnProperty(attr)) {
if (attr !== 'volatile' && query.hasOwnProperty(attr)) {
object[attr] = query[attr];
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Room.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ function Room(collection, options) {
enumerable: true,
writable: true
},
metadata: {
value: (options && options.metadata) ? options.metadata : {},
volatile: {
value: (options && options.volatile) ? options.volatile : {},
enumerable: true,
writable: true
},
Expand Down Expand Up @@ -214,7 +214,7 @@ Room.prototype.renew = function (filters, notificationCB, cb) {
subscribeQuery.body = self.filters;
subscribeQuery = self.kuzzle.addHeaders(subscribeQuery, this.headers);

self.kuzzle.query(self.collection.buildQueryArgs('realtime', 'subscribe'), subscribeQuery, {metadata: self.metadata}, function (error, response) {
self.kuzzle.query(self.collection.buildQueryArgs('realtime', 'subscribe'), subscribeQuery, {volatile: self.volatile}, function (error, response) {
delete self.kuzzle.subscriptions.pending[self.id];
self.subscribing = false;

Expand Down
8 changes: 4 additions & 4 deletions test/Room/constructor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Room constructor', function () {
it('should handle provided arguments correctly', function () {
var room = new Room(collection);

should(room.metadata).be.an.Object().and.be.empty();
should(room.volatile).be.an.Object().and.be.empty();
should(room.subscribeToSelf).be.true();
should(room.scope).be.exactly('all');
should(room.state).be.exactly('done');
Expand All @@ -35,11 +35,11 @@ describe('Room constructor', function () {
scope: 'in',
state: 'pending',
users: 'all',
metadata: {some: 'metadata'},
volatile: {some: 'metadata'},
subscribeToSelf: false
});

should(room.metadata).match({some: 'metadata'});
should(room.volatile).match({some: 'metadata'});
should(room.subscribeToSelf).be.false();
should(room.scope).be.exactly('in');
should(room.state).be.exactly('pending');
Expand All @@ -55,7 +55,7 @@ describe('Room constructor', function () {
should(room).have.propertyWithDescriptor('scope', {enumerable: false, writable: false, configurable: false});
should(room).have.propertyWithDescriptor('state', {enumerable: false, writable: false, configurable: false});
should(room).have.propertyWithDescriptor('users', {enumerable: false, writable: false, configurable: false});
should(room).have.propertyWithDescriptor('metadata', {enumerable: true, writable: true, configurable: false});
should(room).have.propertyWithDescriptor('volatile', {enumerable: true, writable: true, configurable: false});
should(room).have.propertyWithDescriptor('subscribeToSelf', {
enumerable: true,
writable: true,
Expand Down
8 changes: 4 additions & 4 deletions test/kuzzle/constructor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('Kuzzle constructor', function () {
should(kuzzle).have.propertyWithDescriptor('queueMaxSize', { enumerable: true, writable: true, configurable: false });
should(kuzzle).have.propertyWithDescriptor('queueTTL', { enumerable: true, writable: true, configurable: false });
should(kuzzle).have.propertyWithDescriptor('headers', { enumerable: true, writable: true, configurable: false });
should(kuzzle).have.propertyWithDescriptor('metadata', { enumerable: true, writable: true, configurable: false });
should(kuzzle).have.propertyWithDescriptor('volatile', { enumerable: true, writable: true, configurable: false });
should(kuzzle).have.propertyWithDescriptor('replayInterval', { enumerable: true, writable: true, configurable: false });
should(kuzzle).have.propertyWithDescriptor('reconnectionDelay', { enumerable: true, writable: true, configurable: false });
should(kuzzle).have.propertyWithDescriptor('jwtToken', { enumerable: true, writable: true, configurable: false });
Expand All @@ -84,7 +84,7 @@ describe('Kuzzle constructor', function () {
should(kuzzle.queueTTL).be.exactly(120000);
should(kuzzle.queueMaxSize).be.exactly(500);
should(kuzzle.headers).be.an.Object().and.be.empty();
should(kuzzle.metadata).be.an.Object().and.be.empty();
should(kuzzle.volatile).be.an.Object().and.be.empty();
should(kuzzle.replayInterval).be.exactly(10);
should(kuzzle.reconnectionDelay).be.exactly(1000);
should(kuzzle.defaultIndex).be.undefined();
Expand All @@ -102,7 +102,7 @@ describe('Kuzzle constructor', function () {
queueTTL: 123,
queueMaxSize: 42,
headers: {foo: 'bar'},
metadata: {foo: ['bar', 'baz', 'qux'], bar: 'foo'},
volatile: {foo: ['bar', 'baz', 'qux'], bar: 'foo'},
replayInterval: 99999,
reconnectionDelay: 666,
defaultIndex: 'foobar',
Expand All @@ -119,7 +119,7 @@ describe('Kuzzle constructor', function () {
should(kuzzle.queueTTL).be.exactly(options.queueTTL);
should(kuzzle.queueMaxSize).be.exactly(options.queueMaxSize);
should(kuzzle.headers).be.an.Object().and.match(options.headers);
should(kuzzle.metadata).be.an.Object().and.match(options.metadata);
should(kuzzle.volatile).be.an.Object().and.match(options.volatile);
should(kuzzle.replayInterval).be.exactly(options.replayInterval);
should(kuzzle.reconnectionDelay).be.exactly(options.reconnectionDelay);
should(kuzzle.port).be.exactly(options.port);
Expand Down
2 changes: 1 addition & 1 deletion test/kuzzle/methods.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Kuzzle methods', function () {
should(emitted).be.true();

emitted = false;
passedOptions = {queuable: true, metadata: {foo: 'bar'}};
passedOptions = {queuable: true, volatile: {foo: 'bar'}};
kuzzle.getAllStatistics(passedOptions, function () {});
});

Expand Down
18 changes: 9 additions & 9 deletions test/kuzzle/query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ describe('Query management', function () {
should(function () { kuzzle.query(queryArgs, 'foobar'); }).throw(Error);
});

it('should handle options metadata properly', function () {
it('should handle options volatile properly', function () {
var
metadata = {
volatile = {
foo: 'bar',
baz: ['foo', 'bar', 'qux']
};

kuzzle.query(queryArgs, { body: { some: 'query'}}, {metadata: metadata});
should(requestObject.metadata).match(metadata);
kuzzle.query(queryArgs, { body: { some: 'query'}}, {volatile: volatile});
should(requestObject.volatile).match(volatile);
});

it('should handle option refresh properly', function () {
Expand Down Expand Up @@ -207,16 +207,16 @@ describe('Query management', function () {
should(emitted).be.false();
});

it('should copy query local metadata over optional ones', function () {
it('should copy query local volatile over optional ones', function () {
var
metadata = {
volatile = {
foo: 'bar',
baz: ['foo', 'bar', 'qux']
};

kuzzle.query(queryArgs, { body: { some: 'query'}, metadata: {foo: 'foo'}}, {metadata: metadata});
should(requestObject.metadata.foo).be.exactly('foo');
should(requestObject.metadata.baz).match(metadata.baz);
kuzzle.query(queryArgs, { body: { some: 'query'}, volatile: {foo: 'foo'}}, {volatile: volatile});
should(requestObject.volatile.foo).be.exactly('foo');
should(requestObject.volatile.baz).match(volatile.baz);
});

it('should not define optional members if none was provided', function () {
Expand Down