Skip to content

Commit

Permalink
Comment GET endpoints now expand foreign keys if expanded property pr…
Browse files Browse the repository at this point in the history
…ovided
  • Loading branch information
MKHenson committed May 23, 2016
1 parent 85a2ad0 commit 93ff59c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions server/dist/src/controllers/comments-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class CommentsController extends controller_1.Controller {
var instances = yield comments.findInstances(findToken, [sort], parseInt(req.query.index), parseInt(req.query.limit));
var jsons = [];
for (var i = 0, l = instances.length; i < l; i++)
jsons.push(instances[i].schema.getAsJson(instances[i]._id, { verbose: Boolean(req.query.verbose) }));
jsons.push(instances[i].schema.getAsJson(instances[i]._id, { verbose: Boolean(req.query.verbose), expandForeignKeys: Boolean(req.query.expanded) }));
var sanitizedData = yield Promise.all(jsons);
serializers_1.okJson({
error: false,
Expand Down Expand Up @@ -143,7 +143,7 @@ class CommentsController extends controller_1.Controller {
throw new Error("That comment is marked private");
var jsons = [];
for (var i = 0, l = instances.length; i < l; i++)
jsons.push(instances[i].schema.getAsJson(instances[i]._id, { verbose: Boolean(req.query.verbose) }));
jsons.push(instances[i].schema.getAsJson(instances[i]._id, { verbose: Boolean(req.query.verbose), expandForeignKeys: Boolean(req.query.expanded) }));
var sanitizedData = yield Promise.all(jsons);
serializers_1.okJson({
error: false,
Expand Down
4 changes: 2 additions & 2 deletions server/src/controllers/comments-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default class CommentsController extends Controller

var jsons : Array<Promise<mp.IComment>> = [];
for (var i = 0, l = instances.length; i < l; i++)
jsons.push(instances[i].schema.getAsJson<mp.IComment>(instances[i]._id, { verbose : Boolean(req.query.verbose) } ));
jsons.push(instances[i].schema.getAsJson<mp.IComment>(instances[i]._id, { verbose : Boolean(req.query.verbose), expandForeignKeys: Boolean(req.query.expanded) } ));

var sanitizedData = await Promise.all(jsons);

Expand Down Expand Up @@ -170,7 +170,7 @@ export default class CommentsController extends Controller

var jsons : Array<Promise<mp.IComment>> = [];
for (var i = 0, l = instances.length; i < l; i++)
jsons.push(instances[i].schema.getAsJson<mp.IComment>(instances[i]._id, { verbose : Boolean(req.query.verbose) }));
jsons.push(instances[i].schema.getAsJson<mp.IComment>(instances[i]._id, { verbose : Boolean(req.query.verbose), expandForeignKeys: Boolean(req.query.expanded) }));

var sanitizedData = await Promise.all(jsons);

Expand Down

0 comments on commit 93ff59c

Please sign in to comment.