Publishing part of nested array of objects (use aggregations?)


#1

I am trying to publish part of a nested array of objects.

So for example for the following json document:

{
	"offerName": "offer1",
	"books": [{
		"bookName": "Book 1",
		"authors": [{
			"authorName": "A"
		}, {
			"authorName": "B"
		}, {
			"authorName": "C"
		}],
		"bookName": "Book 2",
		"authors": [{
			"authorName": "A"
		}, {
			"authorName": "B"
		}],
		"bookName": "Book 3",
		"authors": [{
			"authorName": "A"
		}]
	}]
}

If I would be logged in as author B I would see the offer object because one of my books is part of the offer object…however I should not be able to see books[2] because books[2].authors it does not include author B…

I would like to create a publication which splices books[2] but i am not sure how to do this on the server side inside a publication.

Even on the client side it would take three nested for loops which isnt ideal. Is is possible to use aggregation for this? Or are there better options?
Thanks
Shibbn


#2

anyone have an idea here?


#3

Use a separate collection instead of nested arrays?


#4

I decided to break this into two parts , one for displaying the entire collection and a method to display to handle single items in a collection.

Its not reactive by default but for the use case its fine