Relational queries- cloud functions

I have 2 tables in database.
User table

Courses table

Im trying to get students of certain course which has the instructor with name “dummyName”.

Moralis.Cloud.define("course_relation", async (request) => {
    courses = Moralis.Object.extend("Courses")
    const relation = courses.relation("Instructor");
    result = await relation.query().equalTo("Name","dummyName").find({useMasterKey: true});
    return result;

this code gives “courses.relation is not a function” error.

how can i use relation function on Courses table ?

Much thanks for any help

You should use relation on an object, not a class.
You can read more about relation here. The first example looks like what you’re trying to do here

you can search on google how to do it with parse server too

it look like you have a pointer there and not a relation in Courses class

I created objects in database not with code. How can i get that object from database ? Queries doesnt work with relation function

Actually it needs to be a relation but i thought it would be easier to solve this problem with a pointer. I will google it thanks!

It is a pointer there on what you have in Courses table, at least in the image that you posted

Yeah i know. I mean i changed it to a Pointer after i get errors with Relation.

It looks like when i try to create new object with a existing objectId, it returns existing object from table.

Is it the only way to get a object from table or am i doing it wrong?