Back

[SOLVED] How can I write a query in the realtime?

  • 1
  • Databases
  • Web
  • Realtime
Sandeep K. Dasari
1 Jun, 2023, 14:26

inside that if conditional!

TL;DR
User is asking for help with writing a query in real-time. There is some unrelated conversation in the thread. The user also mentions adding a member to a team via server SDK and getting an error. The solution is to pass the teamID, email, and an empty array as arguments to the `teams.createMembership()` function. There is also a comment about not being able to add users to a team directly but only through email/phone invites. The user asks about creating a team for every group creation, and it is recommended to do so. The user also asks about the meaning of "query" in a specific context, but there
Binyamin
1 Jun, 2023, 14:34

What you mean by query Inside that If you already gonna have the new message document object

Sandeep K. Dasari
1 Jun, 2023, 14:52

Thank you so much!

Sandeep K. Dasari
1 Jun, 2023, 14:54

So, @Binyamin Do I need to create a team for every Group creation in my application! right?

Binyamin
1 Jun, 2023, 15:02

Yes, that would be a quick and efficient way to gather room users and will make the document real-time fetching worry free

Sandeep K. Dasari
1 Jun, 2023, 15:06

[SOLVED] How can I write a query in the realtime?

punti_z
1 Jun, 2023, 15:06

The only issue currently which makes teams not a friendly option is you cannot just add a user to a team. Any team additions are based on email/phone invites

Sandeep K. Dasari
1 Jun, 2023, 15:06

Ohh is it?

punti_z
1 Jun, 2023, 15:06

Even using server side functions you cannot add users to a team

Binyamin
1 Jun, 2023, 15:07

You can with server side sdk https://appwrite.io/docs/server/teams?sdk=nodejs-default#teamsCreateMembership

If initiated from a Server SDK, the new member will be added automatically to the team.

Sandeep K. Dasari
1 Jun, 2023, 15:07

Then A typical who wants to join a chatting group like this discord, How can i implement this?

Binyamin
1 Jun, 2023, 15:09

Why not? I've done that inside a function.

punti_z
1 Jun, 2023, 15:11

Interesting, what do you pass for URL if the user is already registered ?

Binyamin
1 Jun, 2023, 15:13

This is part my function code.

TypeScript
async function addUserToTeam(teamID,email) {
    client
        .setEndpoint('https://cloud.appwrite.io/v1')
        .setProject(projectID)
        .setKey(apiKey)
        .setSelfSigned(true);

    try {
        const r = await teams.createMembership(teamID, email, [], '');
    } catch (e) {
          //
    }
}
Binyamin
1 Jun, 2023, 15:15

It works both ways

punti_z
1 Jun, 2023, 15:16

Sweet, glad in jumped into this thread. Now I need to update a bunch of logic in my app 🙂 .. Thanks @Binyamin

Binyamin
1 Jun, 2023, 15:16

<:appwritefire:823999000330895380>

Sandeep K. Dasari
1 Jun, 2023, 16:47

Are you building chat application too?

Sandeep K. Dasari
1 Jun, 2023, 16:47

Are you participating in appwrite's hackathon too?

Binyamin
1 Jun, 2023, 16:50

Hopefully if I'll be able to delivery till the deadline.

Sandeep K. Dasari
1 Jun, 2023, 16:50

Amazing!

Sandeep K. Dasari
1 Jun, 2023, 16:51

what are you building by the way? @Binyamin

Binyamin
1 Jun, 2023, 16:54

I had few ideas, maybe a URL shortener

punti_z
10 Jun, 2023, 16:11

Hey Binyamin, tried adding member to a team via server SDK and blank URL and get the error Invalid URL :/

Drake
10 Jun, 2023, 21:57

You can put your Appwrite endpoint.

In the future, it's best to create a separate post rather than reusing someone else's thread, especially for something unrelated to the original post

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more