WIP: initial prototype
- Do not serilize keys with undefined values in querystring - Added promises support in Transport.request
This commit is contained in:
@ -49,7 +49,10 @@ class Serializer {
|
||||
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) {
|
||||
// elasticsearch will complain for keys without a value
|
||||
if (object[key] === undefined) {
|
||||
delete object[key]
|
||||
} else if (Array.isArray(object[key]) === true) {
|
||||
object[key] = object[key].join(',')
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,10 +34,21 @@ class Transport {
|
||||
}
|
||||
|
||||
request (params, options, callback) {
|
||||
options = options || {}
|
||||
if (typeof options === 'function') {
|
||||
callback = options
|
||||
options = {}
|
||||
}
|
||||
|
||||
// promises support
|
||||
if (callback == null) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.request(params, options, (err, result) => {
|
||||
err ? reject(err) : resolve(result)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
callback = once(callback)
|
||||
// TODO: return in the result the metadata
|
||||
const meta = {
|
||||
|
||||
Reference in New Issue
Block a user