Skip to content

Commit bd796a0

Browse files
committed
fix(findAll): passes response metadata to findAll
1 parent 43c5702 commit bd796a0

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,7 @@ Component.extend({
847847
*/
848848
find (mapper, id, opts) {
849849
let record, op
850+
let meta = {}
850851
opts || (opts = {})
851852
opts.with || (opts.with = [])
852853

@@ -859,11 +860,12 @@ Component.extend({
859860
return utils.resolve(this._find(mapper, id, opts))
860861
})
861862
.then((results) => {
862-
let [_record] = results
863+
let [_record, _meta] = results
863864
if (!_record) {
864865
return
865866
}
866867
record = _record
868+
meta = _meta
867869
const tasks = []
868870

869871
utils.forEachRelation(mapper, opts, (def, __opts) => {
@@ -889,7 +891,7 @@ Component.extend({
889891
return utils.Promise.all(tasks)
890892
})
891893
.then(() => {
892-
let response = new Response(record, {}, 'find')
894+
let response = new Response(record, meta, 'find')
893895
response.found = record ? 1 : 0
894896
response = this.respond(response, opts)
895897

@@ -924,6 +926,7 @@ Component.extend({
924926
opts.with || (opts.with = [])
925927

926928
let records = []
929+
let meta = {}
927930
let op
928931
const activeWith = opts._activeWith
929932

@@ -945,9 +948,10 @@ Component.extend({
945948
return utils.resolve(this._findAll(mapper, query, opts))
946949
})
947950
.then((results) => {
948-
let [_records] = results
951+
let [_records, _meta] = results
949952
_records || (_records = [])
950953
records = _records
954+
meta = _meta
951955
const tasks = []
952956
utils.forEachRelation(mapper, opts, (def, __opts) => {
953957
let task
@@ -971,7 +975,7 @@ Component.extend({
971975
return utils.Promise.all(tasks)
972976
})
973977
.then(() => {
974-
let response = new Response(records, {}, 'findAll')
978+
let response = new Response(records, meta, 'findAll')
975979
response.found = records.length
976980
response = this.respond(response, opts)
977981

0 commit comments

Comments
 (0)