Open cyclops24 opened 8 years ago
@cyclops24 customer.name
is automatically filled with join described in previous customerId
field.
These three lines of code:
"join_collection": "customers",
"join_fields": ["name"],
"join_container": "customer"
join_collection
- from which (foreign) collection we want to join data into this collection?
join_fields
: - which fields we want to fetch from foreign collection?
join_container
: - field name in which data will be fetched from foreign collection, in this case customer
- you can name it as you wish.
Now, result from this is that Invoices.find/findOne will return something like this:
{
...normal fields from Invoices collection...
"customer": {
"name": "Bruce Lee"
}
}
If you change join rules to this:
{
"join_collection": "customers",
"join_fields": ["name", "email"],
"join_container": "foo"
}
Results will be:
{
...normal fields from Invoices collection...
"foo": {
"name": "Bruce Lee",
"email": "bruce@hongkong.com"
}
}
This is automatically performed by perak:joins
package. Look at docs to see how to perform the same thing manually without kitchen.
Thanks @perak ,
I try to add this feature to my project and after some try find this small bug:
when you enable collection2 support project not compile and crashed with this error message:
Unexpected token
and after remove "use_collection2": true,
all things worked well.
If need I can post it as new issue in kitchen-website repository.
Hi @perak , I have a simple question. In the example-invoices how do transform and show customer name in rather than id the DataView?? I talk about this page. I read json file a lot but I don't understand. You have this two field in collection definition but how to fill customer.name: