bajo-db-restproxy
Version:
Bajo DB REST Proxy Client driver for Bajo Framework
14 lines (12 loc) • 414 B
JavaScript
async function find ({ url, opts, schema, filter, options } = {}) {
if (options.count) opts.headers['X-Count'] = true
if (options.rels) opts.headers['X-Rels'] = options.rels
const sorts = []
for (const s in filter.sort) {
sorts.push(`${s}:${filter.sort[s]}`)
}
if (sorts.length > 0) opts.params.sort = sorts.join('+')
delete filter.sort
return { url, opts }
}
export default find