Back

[SOLVED] Cannot Access Queries.equal() on server side

  • 0
  • Self Hosted
Aarush Acharya
2 Nov, 2023, 19:44

This is my code

TL;DR
Title: [SOLVED] Cannot Access Queries.equal() on server side Solution: Use `sdk.Query.equal()` instead of instantiating an object with `sdk.Query()`. The correct import statement is `const sdk = require("node-appwrite");`. Refer to the appwrite documentation for the correct usage of `sdk.Query.equal()`.
Aarush Acharya
2 Nov, 2023, 19:45

While this is my error

Aarush Acharya
2 Nov, 2023, 19:46
Aarush Acharya
2 Nov, 2023, 19:48

I looked into the appwrite SDK code as well The equal method is well defined, in it

Drake
2 Nov, 2023, 19:48

yes, but you're not using it right

Aarush Acharya
2 Nov, 2023, 19:56

thanks but I did refer that quite some times I cannot use this line

import { Client, Databases, Query } from "appwrite";

gives me a bunch of error on server side

but importing like this works const sdk = require("node-appwrite");

But this does not seem to work const query = sdk.Query() So was trying to do it that way

Drake
2 Nov, 2023, 19:57

well appwrite is the web sdk...given the docs, how do you think you'd do it with the node sdk?

Aarush Acharya
2 Nov, 2023, 19:58

I tried doing with

Aarush Acharya
2 Nov, 2023, 20:00
TypeScript
const sdk = require("node-appwrite");

const query = sdk.Query();

// Now while using
query.equal(attribute, value);
// this should have worked I guess```
Drake
2 Nov, 2023, 20:02

well that didn't work and that doesn't look like the docs, right?

Aarush Acharya
2 Nov, 2023, 20:07
Aarush Acharya
2 Nov, 2023, 20:08

I will try doing import { Client, Databases, Query } from "node-appwrite";

Drake
2 Nov, 2023, 20:08

no, your import is fine

Aarush Acharya
2 Nov, 2023, 20:09

I am sorry I am not able to catch the correction

Aarush Acharya
2 Nov, 2023, 20:09

I guess it is in function calling maybe

Aarush Acharya
2 Nov, 2023, 20:10

line query.equal() I mean

Drake
2 Nov, 2023, 20:11

right, that's the incorrect part. does that look like what's in the docs?

Henry_Dustin
2 Nov, 2023, 20:15

sir please reply my message

Aarush Acharya
2 Nov, 2023, 20:18

Thanks a lot @Steven It clicked me

Aarush Acharya
2 Nov, 2023, 20:20

Instead of this now doing

TypeScript
const query = sdk.Query;
query.equal();

Now I can access the equal function correctly thanks a lot

Aarush Acharya
2 Nov, 2023, 20:20

[SOLVED] Cannot Access Queries.equal() on server side

Drake
2 Nov, 2023, 20:43

more specifically, it's just sdk.Query.equal(). the sdk.Query is the same as the Query in the web sdk. the big difference is just in how it's imported when doing import vs require. you can even do:

TypeScript
const sdk = require("node-appwrite");
const { Client, Databases, Query } = sdk;
Drake
2 Nov, 2023, 20:44

that's how static functions are invoked. you don't need to instantiate an object

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