WIP: initial prototype
- Added querystring support - Added support for already serialized bodies
This commit is contained in:
@ -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
|
||||
|
||||
Reference in New Issue
Block a user