How to get IDs of channels under a category? - discord.js

Channels have parent_id that returns the category they're in, but is there anything like a child_id that could give me the channels a category has in it?

It's not so much an ID but a collection but yes. Each categoryChannel has a .children property that returns all channels inside the category.
https://discord.js.org/#/docs/main/stable/class/CategoryChannel?scrollTo=children

Related

Elasticsearch equivalent of NOT IN (SELECT ..)

We have something like this (we save an item for each episode, show and user. And all items are saved on the same index.):
and we need to list all episodes from a show, but we need to filter the episodes already watched by the user.
In PostgreSQL i would have run something like this:
SELECT * FROM Episode WHERE show_id = 'showID' AND episode_id NOT IN (SELECT episode_id FROM watched WHERE user_id = 'userId')
But since we are using Elasticsearch, we are not sure what would be the alternative.
We also assume that the watched list is going to scale, so we can't just send an array of ids to ES.
Is there a way for Elasticsearch to handle all the logic, and filter from a dynamic array of values on a single query.
We just used joins, and has_child.
We filter all parents that have a watched child item.

Query of Arrays in Salesforce

I need to do 1 of two things (I believe):
1- Get a Custom Object ID so I can query it directly
2- Get a list of values of a specific field within the Object entries.
Ultimate End goal:
Add and modify rows in my custom object via external API. However to do this I need to check and make sure my new entry/row does not already exist.
What I have:
I have a custom object (called Customer_Arrays__c). It is a table that I can add new rows to (I will call entrys). Each entry has 6 or 7 fields. 1 of these fields is called (external_ID__c). This is the field I utilize to match to new incoming data to see if the entry already exists, or if it needs to add a new row to my table. This Customer_Arrays__c is a child to my opportunity I believe – it is part of every opportunity and each line item I add has a field defaulted to the opportunity.
Help I need:
1- How do I query the value of my Cutomer_Arrays__c based upon an opportunity ID?
2- How do I query a list of values in my (external_ID__c) based upon an opportunity ID?
Thanks for your help! I have read half a dozen+ posts on similar topics and am missing something. Examples of some Past try's that failed:
Select external_ID__c,FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id (Select ID, Custom_Arrays__c from Custom_Arrays__c) from Opportunity where id ='00...'
List FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id, external_ID__c, (Select external_ID__c FROM Custom_Arrays__c) WHERE Opportunity__c='00...'
Thanks again!
Only you know how did you name the lookup field (foreign key) from arrays to Opportunity. You'll need to check in setup, next to where external_ID__c is. Since it's a custom field (gets __c at the end), my guess is you went with default.
Try
SELECT Id, Name, External_Id__c
FROM Customer_Arrays__c
WHERE Opportunity__c = '006...'
Thank you eyescream, that got me almost all the way there. Turns out I also needed a __r for the parent child relationship.
Here is a snip out of my final code that works - I think it covers everything:
SELECT Field1__c, Opportunity__r.Id, Opportunity__r.Opportunity__c,
FROM Customer_Arrays__c
WHERE Opportunity__r.Id = '006...'.
Thank you so very much!!!

Data Category Visibility Issue

I am facing Data Category visibility related issue.
The scenario is i'm following -
I have One Community User which one is using for login into my community.
This User's role is Inheriting Visibility for Category Group from it's parant role and it's Visibility is No categories are visible to parent role and subordinates.
But This User's Permission set have Custom Visibility Permission is like -
All Category Group > child Category > sub child Category
for ex :
All Products > Computers > Laptops
And I am accessing lick bellow query from apex to display related article in community.
Select Id, Title, KnowledgeArticleId, Summary, CreatedDate, UrlName From KnowledgeArticleVersion WHERE Language = 'en_US' and PublishStatus='Online' WITH DATA CATEGORY Products at (Computers__c) limit 10 UPDATE VIEWSTAT
but I am not getting any articles.
getting error like --
Invalid data category name provided: Products. There is no data category matching the given developer name on the data category group: Computers__c
If anyone have solution for this please let me know.
Thank you,
Harsiddhi.
You probably have already figured this out by now, however you need to use the API name for your Group as well, i.e. 'Products' becomes 'Products__c'.
Should be something more like this:
Select Id, Title, KnowledgeArticleId, Summary, CreatedDate, UrlName From KnowledgeArticleVersion WHERE Language = 'en_US' and PublishStatus='Online' WITH DATA CATEGORY Products__c at (Computers__c)
Queries are not dependent on permission sets.
The error in the SOQL query can be looked upon at the query editor. Whenever there is a wrong API name in the query, there comes down an indication in the Query Editor under Developer Console that:
No such column 'field_name' on entity
Thus we can look back at the object fields and relationships and can ensure if the right API name is there.

Salesforce apex collaborationgroup/collaborationgroupmember relationship?

I'm trying to get a list of collaboration groups and their associated members. I'm trying to do the following soql query but it does not recognise the CollaborationGroup.CollaborationGroupMembers relationship
List<CollaborationGroup> cgs = new List<CollaborationGroup>([Select OwnerId, Id, (select CollaborationGroupMember.MemberId from CollaborationGroup.CollaborationGroupMembers) From CollaborationGroup]);
Looking at the API, CollaborationGroupMembers has a CollaborationGroupId which is the ID of the associated CollaborationGroup, so the relationship should exist - can anyone tell me why it's not working?
Thanks
J
edit: I have figured this out the other way round (going from member to group (child to parent) rather than vice-versa) by doing the following:
List<CollaborationGroupMember> cgs = new List<CollaborationGroupMember>([select MemberId, CollaborationGroupMember.CollaborationGroup.OwnerId from CollaborationGroupMember where CollaborationGroupMember.CollaborationGroup.Name]);
However, I'd still like to know why I couldn't do it from parent to child as I was trying to in the first place?
Thanks
As per the documentation here, it's not having a relation from CollabarationGroup into CollabarationGroupMember. But as you have mentioned, it's having the relation in the otherway around, see this. So if you need to collect members from a particular group you can try
SELECT MemberId FROM CollaborationGroupMember WHERE CollaborationGroupId='your_group_id'
or filter it from CollaborationGroup.Name as you are already doing.

Chained reverse lookups in Django

I have [profile] --M2M--> [group] --FK--> [group category].
Given an instance of [group category], I need to retrieve all related [profile].
(In english: I have members belonging to one or more groups, which are in categories. I need to find all the members in a given category of group).
How do I span the ForeignKey and ManytoMany keys in between? No matter how I slice this, I always end up with an expression from which I can't define the next backward relationship.
Thank you.
Assuming something like:
object Profile():
groups = models.ManyToManyField('Group')
object Group():
category = models.ForeignKey('GroupCategory')
You should be able to just query it:
profiles = Profile.objects.filter(groups__category=thegroupcategory)

Resources