I have a 'products' and 'categories' colleciton, then a juntion table 'producst_categories'
On products my products_categories field is a many-to-many and configured to use the juntion table as so:
But when I view the response for showing all products the products_categories is returning the products_id not the categories_id
Your M2M relationship looks correct, so my guess is that your API request is only returning the parent item. If you want to fetch deeper/relational data (not just the ID/PK) then you'll need to use the fields parameter:
It uses dot-notation for the depth — with wildcards (*) for all fields, or exact field names. For example:
?fields=*.*.*
// OR...
?fields=products.categories.name
https://docs.directus.io/api/query/fields.html
https://docs.directus.io/getting-started/troubleshooting.html#why-is-my-relational-data-file-only-returning-an-id
Related
I have run into a little roadblock in regards to joining mantle entities. I would like to have a single depicting fields from two mantle entities, but am unsuccessful in joining them. Specifically, I have linked a list of party relationships (as contacts) to a single partyId (vendor), with the goal to make a vendor contacts page. However I am unable to link that form-list with the PartyContactMech and ContactMech entities (in order to display email and phone number in the same form-list). More generally, my question is how can one map lists to each other the same way one can map a list to a single object (using entity-find-one and value-field does not work when tried with entity-find)?
There is no need to make a view-entity (join entities) to do that. Simply do a query on the PartyRelationship entity in the main 'actions' part of your screen specifying the toParty (vendor). Then in your Form-List, use 'row-actions' to query the PartyContactMech and so on for each fromPartyId (contact) entry that the previous query returned. Also have a look at the PartyViewEntities file in Mantle USL. There are some helpful view-enties already defined for you there such as PartyToAndRelationship, PartyFromAndRelationship etc. Also note that entity-find-one returns a single "map" (value-field) as it queries on the PK. Whereas entity-find returns a list of maps (list). They are separate query types. If I understand your question correctly.
I have Products in my SOLR index. I need to create calculated fields for each product. These fields are based on product's children.
Is it possible to create such calculated fields?
For example, I have a Product with id 1, I need to add all the Detail entities, which have "parentId" field value 1. Here is a brief schema: https://www.screencast.com/t/EkNG8NpFp.
I need to have values "v1", "v3" from the example above.
not sure what you exactly mean by "create such calculated fields"...
if you mean if you can query for Products and then for example get the average of field 'value'. Yes you can do stuff like that, look at json facets and how you can use children docs.
if you mean how you can add some new field to your Product doc, based on the values of the children docs, then you can probably do it with Streaming Expressions. You need to use the current collection as a source, and compute the new fields, and finally add the new docs (including the new field) into a new collection
I'm trying to do some resolution between restaurants in my DB to their respective Foursquare id. For example, there's a Steakhouse (a subcategory of the Food category) in Penang, MY called 'Suffolk House', but when I specify the categoryId non-Food related venues still show up in the result group.
https://api.foursquare.com/v2/venues/search?categoryId=4d4b7105d754a06374d81259&intent=match&ll=5.4112879000000,100.305271200000&query=Suffolk&client_id=XXXXXXX&client_secret=XXXX
You'd expect only results belonging withing a category (or subcategory) would come back. What gives? Is categoryId really a no-op parameter?
The categoryId parameter is not currently supported for intent=match. You can either filter the results by category afterwards, or use a different intent if you need category matches.
In Django, if I have a model such as a Building which is OneToOne related to a (Django Auth) Group containing users, how can I find all the buildings to User belongs to (maybe those are all the buildings the User works in)? Building is one to one with Group so building has a group foreign key field called 'group'.
I've tried
Building.objects.filter(group__contains=user)
Building.objects.filter(group_user_set__contains=user)
I'm getting no matches when there should be matches.
Using contains is not the right choice since it searches for expression inside field (string) not within the set. Try using:
Buildings.objects.filter(group__user=user)
If it's a one to one relationship why not just return the groups?
result = []
u = User.objects.get(your user here)
for group in u.groups.all():
result.append(group.whateverYourForeignKeyFieldIsCalled)
return result
We use Oracle's ATG Web Commerce for our project. And currently we need construct RQL query which obtain products which SKU's tacticalTradeStatuses contains certain status and ordered by status value.
I briefly describe the relationship between entities: Product item descriptor contains list of SKUs. Each SKU contains map tacticalTradeStatuses (key - tactical trade status, value - sequense)
For example, how to obtain all products which SKU's tacticalTradeStatuses property contains key 'BEST_SELLER' and ordered by value associated with key 'BEST_SELLER'.
Key by which we want to select products we want to pass as RQL parameter.
i have two ways to doing that
1) first create a query which fetches all the product based on map key BEST_SELLER
2) Now pass it to foreach droplet and add sort properties. which help to sort the result based on your requirements
for sorting please refer to below link
http://docs.oracle.com/cd/E23095_01/Platform.93/PageDevGuide/html/s1316foreach01.html
2 way i think is to use query options in RQLStatement.. which work same as sort properties in for each
If you provide some XML Repository structure that will be good..hope it will help you