Restructure the JSON format

I’m doing a findOne like below to get all the sets within a document but having issues structuring it like the target format below. Is there a clean way to insert the ‘quoteLines: [{’ at the front of it?

Thanks!

$scope.detail = Quotes.findOne({_id: $stateParams.quoteId}).quoteLines;

$scope.detail = {
quoteLines: [{
productId: “SPANNER”,
qty: 1,
price: 5
}, {
productId: “BOLT”,
qty: 100,
age: 10
}],
selected: {}
};

if (!$scope.detail) {
  $scope.detail = {};
}
$scope.detail.quoteLines = Quotes.findOne({_id: $stateParams.quoteId}).quoteLines;
1 Like

Use JSON Pretty Print tool.