I am using Parse for Group Chat and Private Chat both.
I get stuck in a situation
where in Chat("one table using for both private and group")
there are columns such as
"Groupid, Senderid, ReceiverId and Status"
Here one user sends more than one text msgs so I want to collect all the chats of that user in One Group so one user can have joined more than 1 groups so I want the all chats of particular group in one bunch so if there are chats in 5 groups then there should 5 objects with their chats such as Group By functionality.
Related
I am using the Graph API to create an event in a group calendar and I invite another group.
Group A creates Event E and invites Group B.
In the POST request, I will set categories which are correctly shown for Group A.
But using a GET request to get the meeting that arrived at Group B the categories are gone in the JSON response.
Yes, categories are not synchrnoized between groups, but I would assume that when sending a meeting request to a group, the categories should still get send?
Please go ahead and raise a feature request to synchronize categories between groups here https://microsoftgraph.uservoice.com/forums/920506-microsoft-graph-feature-requests so that the corresponding team can look into the possibility of picking it up for implementation in the future.
I am developing a system in which it will have a chat system between two user tables: the clients and the engineers. My problem is how to make these two tables communicate in one message table with regard to registering the sender ID and recipient ID since both can change and are in different tables.
My initial thought for this was two tables where I would use the polymorphic relationship:
chats
id
client_id
engineer_id
messages
id
chat_id
senderable_id
senderable_type
receiverable_id
receiverable_type
content
What would be the most recommended way to solve this problem?
First of all, the following its the generic way that I see to create a chat schem. It'll works to a chat with 2 users or more than 2 users.
Note, the user_chat table its the pivot table between users and chats. You can define an alias to that table, like "participants", because it what it means. You can add more attributes to chats table, but basically need to know the creator.
Finally, the secret in messages table is just to get the sender id from users table, because sender and receiver are relative concepts in this context.
Another more simple and reduced way to do it (if you are trying to make a chat with only 2 users) is:
I have one problem with designing database structure for my app. I have 3 models: Events, groups and users.
Relations:
Events - Users - many to many.
Groups - Users - many to many.
There will be available one chat withing group and one inside event. Additonally in the near future I am going to implement chats between two or more users.
I'm a bit confused what is the best way to design it. I created Chat model and many to many relation between chat and users.
First idea: The members of group and event chats will be stored in respectively event_users and group_users tables. Only chats between users will be stored in chat_users.
Second idea: chat_users will be synchronized with event_users and group_users tables. The advantage of this way is that I will have simple separated logic to manage chats and there will be not many complicated queries to DB.
Thanks for any feedback or maybe other ideas.
I believe that Chat has a polymorphic association with Group and Event (and maybe User as well). Some solutions to the problem are provided here:
https://www.slideshare.net/billkarwin/practical-object-oriented-models-in-sql/29-Polymorphic_Assocations_Solutions_Exclusive_arcs
Could something like this work?
ChatUser
id
user_id
chat_id
Chat (exclusive arcs method)
id
event_id (nullable)
group_id (nullable)
description/etc
ChatMessage
id
chat_id
user_id_from
user_id_to (nullable)
date
message
Assumptions made:
event/group can contain multiple chats
user can belong to a group but not to group chat
Besides, Laravel comes with a native polymorphic relation handling solution. It could fit here as well.
User can participate to an event and event can have many users who participate to that event, in this specific case we need to use as Many to Many relation Laravel One to Many Relation
event_user
id
event_id
user_id
User can be member of many group and a group can avec many member, in this case we need a Many to Many relation Laravel Many to Many Relation
group_user
id
group_id
user_id
chat can be related to an event or a group, so we save the type of the chat witch can be either Event or Group and the corresponding ID of that event or group. so if we have a particular chat we can retreive all users related to that chat through the corresponding event or group it depending of the chatable_type in each case, to learn more see Laravel Many To Many Polymorphic Relations
chats
id
name
chatable_id
chatable_type
we need also one table to save all conversations for specific chat
messages
id
chat_id
message
created_at
and for users chat you can create a separate table witch can save the related information about that chat specifiquely
conversations
id
sender_id
receiver_id
message
all sender_id and receiver_id will be foreign key witch reference some id on users table
What is the correct way to relate users in parse to one another as friends?
I also want users to be able to query other users but not see all fields, like emails. Is there a way I can create a view on the users table with cloud code, and only return this to the client code?
I was thinking I can create a friends table that will have two columns with 2 pointers, 1 for each user.
thanks for any advice.
I was thinking I can create a friends table that will have two columns with 2 pointers, 1 for each user.
I'll do that too, with a status column to handle pending, blocked...etc
I also want users to be able to query other users but not see all fields, like emails.
You have to add a privateData column on user with ACL restricted to owner only, which would contain private infos such as emails...etc
I have an Event model and a method called getEvents() which gets a list of events from my events table in my database.
Each event will in turn have delegates associated with it, and this is were it becomes complicated.
There are 3 tables, delegate_event (this is a pivot table, that links the delegates to an event based on event_id and delegate_id), delegates (a simple table containing an id field and a contact_id field) and a contacts table which contains information on a list of contacts.
The delegates table uses the contact_id to link to the contacts table and pull through various pieces of information associated with that contact.
I am using Query Builder and the leftJoin method to get most of the information I need for each event but I now need to pull through a list of delegates. http://paste.laravel.com/qSa
I can't work out how to join the contacts associated with delegates that are associated to the event via the delegate_event table.
Can someone help me out here please. Thanks.
You need a many-to-many table for event-user because multiple events will have multiple users (delegates) associated with it.
Here's what I have:
mtm_event_user: ID, event, user
events: id, name (of event)
users: id, contact
contacts: id, name, address, etc
Here's the query I have, you can modify the SELECT to suit which fields you need.
SELECT *
FROM contacts
INNER JOIN users ON users.contact = contacts.ID
INNER JOIN mtm_event_user AS meu ON meu.user = users.id
WHERE meu.`event` = 1
For multiple events, replace WHERE meu.event = 1 with ORDER BY meu.event