Skip to content

Commit bb4d31c

Browse files
committed
renamed KuzzleDocument.toJSON to serialize
1 parent 8fdcc41 commit bb4d31c

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

dist/kuzzle.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,7 @@ KuzzleDataCollection.prototype.createDocument = function (id, document, options,
16321632
}
16331633

16341634
if (document instanceof KuzzleDocument) {
1635-
data = document.toJSON();
1635+
data = document.serialize();
16361636
} else {
16371637
data.body = document;
16381638
}
@@ -1838,7 +1838,7 @@ KuzzleDataCollection.prototype.publishMessage = function (document, options) {
18381838
var data = {};
18391839

18401840
if (document instanceof KuzzleDocument) {
1841-
data = document.toJSON();
1841+
data = document.serialize();
18421842
} else {
18431843
data.body = document;
18441844
}
@@ -2302,7 +2302,7 @@ function KuzzleDocument(kuzzleDataCollection, documentId, content) {
23022302
*
23032303
* @return {object} JSON object representing this document
23042304
*/
2305-
KuzzleDocument.prototype.toJSON = function () {
2305+
KuzzleDocument.prototype.serialize = function () {
23062306
var
23072307
data = {};
23082308

@@ -2323,7 +2323,7 @@ KuzzleDocument.prototype.toJSON = function () {
23232323
* @return {string} serialized version of this object
23242324
*/
23252325
KuzzleDocument.prototype.toString = function () {
2326-
return JSON.stringify(this.toJSON());
2326+
return JSON.stringify(this.serialize());
23272327
};
23282328

23292329
/**
@@ -2350,15 +2350,15 @@ KuzzleDocument.prototype.delete = function (options, cb) {
23502350
}
23512351

23522352
if (cb) {
2353-
this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'delete'), this.toJSON(), options, function (err) {
2353+
this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'delete'), this.serialize(), options, function (err) {
23542354
if (err) {
23552355
return cb(err);
23562356
}
23572357

23582358
cb(null, self);
23592359
});
23602360
} else {
2361-
this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'delete'), this.toJSON(), options);
2361+
this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'delete'), this.serialize(), options);
23622362
}
23632363

23642364
return this;
@@ -2416,7 +2416,7 @@ KuzzleDocument.prototype.refresh = function (options, cb) {
24162416
*/
24172417
KuzzleDocument.prototype.save = function (options, cb) {
24182418
var
2419-
data = this.toJSON(),
2419+
data = this.serialize(),
24202420
self = this;
24212421

24222422
if (options && cb === undefined && typeof options === 'function') {
@@ -2451,7 +2451,7 @@ KuzzleDocument.prototype.save = function (options, cb) {
24512451
* @returns {*} this
24522452
*/
24532453
KuzzleDocument.prototype.publish = function (options) {
2454-
var data = this.toJSON();
2454+
var data = this.serialize();
24552455

24562456
this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'publish'), data, options);
24572457

dist/kuzzle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/kuzzle.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/kuzzleDataCollection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ KuzzleDataCollection.prototype.createDocument = function (id, document, options,
213213
}
214214

215215
if (document instanceof KuzzleDocument) {
216-
data = document.toJSON();
216+
data = document.serialize();
217217
} else {
218218
data.body = document;
219219
}
@@ -419,7 +419,7 @@ KuzzleDataCollection.prototype.publishMessage = function (document, options) {
419419
var data = {};
420420

421421
if (document instanceof KuzzleDocument) {
422-
data = document.toJSON();
422+
data = document.serialize();
423423
} else {
424424
data.body = document;
425425
}

src/kuzzleDocument.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function KuzzleDocument(kuzzleDataCollection, documentId, content) {
9999
*
100100
* @return {object} JSON object representing this document
101101
*/
102-
KuzzleDocument.prototype.toJSON = function () {
102+
KuzzleDocument.prototype.serialize = function () {
103103
var
104104
data = {};
105105

@@ -120,7 +120,7 @@ KuzzleDocument.prototype.toJSON = function () {
120120
* @return {string} serialized version of this object
121121
*/
122122
KuzzleDocument.prototype.toString = function () {
123-
return JSON.stringify(this.toJSON());
123+
return JSON.stringify(this.serialize());
124124
};
125125

126126
/**
@@ -147,15 +147,15 @@ KuzzleDocument.prototype.delete = function (options, cb) {
147147
}
148148

149149
if (cb) {
150-
this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'delete'), this.toJSON(), options, function (err) {
150+
this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'delete'), this.serialize(), options, function (err) {
151151
if (err) {
152152
return cb(err);
153153
}
154154

155155
cb(null, self);
156156
});
157157
} else {
158-
this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'delete'), this.toJSON(), options);
158+
this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'delete'), this.serialize(), options);
159159
}
160160

161161
return this;
@@ -213,7 +213,7 @@ KuzzleDocument.prototype.refresh = function (options, cb) {
213213
*/
214214
KuzzleDocument.prototype.save = function (options, cb) {
215215
var
216-
data = this.toJSON(),
216+
data = this.serialize(),
217217
self = this;
218218

219219
if (options && cb === undefined && typeof options === 'function') {
@@ -248,7 +248,7 @@ KuzzleDocument.prototype.save = function (options, cb) {
248248
* @returns {*} this
249249
*/
250250
KuzzleDocument.prototype.publish = function (options) {
251-
var data = this.toJSON();
251+
var data = this.serialize();
252252

253253
this.kuzzle.query(this.dataCollection.buildQueryArgs('write', 'publish'), data, options);
254254

test/kuzzleDocument/methods.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,20 +57,20 @@ describe('KuzzleDocument methods', function () {
5757
it('should serialize itself properly', function () {
5858
var
5959
document = new KuzzleDocument(dataCollection, {some: 'content'}),
60-
serialized = document.toJSON();
60+
serialized = document.serialize();
6161

6262
should(serialized._id).be.undefined();
6363
should(serialized._version).be.undefined();
6464
should(serialized.body).be.an.Object().and.match({some: 'content'});
6565

6666
document.id = 'foo';
67-
serialized = document.toJSON();
67+
serialized = document.serialize();
6868
should(serialized._id).be.exactly('foo');
6969
should(serialized._version).be.undefined();
7070
should(serialized.body).be.an.Object().and.match({some: 'content'});
7171

7272
document.version = 42;
73-
serialized = document.toJSON();
73+
serialized = document.serialize();
7474
should(serialized._id).be.exactly('foo');
7575
should(serialized._version).be.exactly(42);
7676
should(serialized.body).be.an.Object().and.match({some: 'content'});
@@ -86,7 +86,7 @@ describe('KuzzleDocument methods', function () {
8686
it('should stringify itself properly', function () {
8787
var
8888
document = new KuzzleDocument(dataCollection, 'id', {some: 'content', _version: 42}),
89-
serialized = document.toJSON(),
89+
serialized = document.serialize(),
9090
stringified = document.toString();
9191

9292
should(stringified).be.a.String();

0 commit comments

Comments
 (0)