WIP: initial prototype

- Added querystring support
- Added support for already serialized bodies
This commit is contained in:
delvedor
2018-10-26 19:04:45 +02:00
parent 8429ad28d9
commit 51e6c76511
3 changed files with 34 additions and 8 deletions

View File

@ -1,5 +1,6 @@
'use strict'
const { stringify } = require('querystring')
const debug = require('debug')('elasticsearch')
const { SerializationError, DeserializationError } = require('./errors')
@ -35,6 +36,19 @@ class Serializer {
}
return ndjson
}
qserialize (object) {
debug('qserialize', object)
// arrays should be serialized as comma separated list
const keys = Object.keys(object)
for (var i = 0, len = keys.length; i < len; i++) {
var key = keys[i]
if (Array.isArray(object[key]) === true) {
object[key] = object[key].join(',')
}
}
return stringify(object)
}
}
module.exports = Serializer