[SOLVED] Moralis.Object.extend error when update from V1 to V2

error on Parse self-host server

useMasterKey will not work in front end

you can try to call a cloud function that makes that query in the database

does this table named Transactions exist in the database?

Ok bro,
If update to V2, we must call cloud functions for all.

Transactions exits in DB. Still working if I using V1.
image

I don’t know exactly what is the issue here, you can try to add more logging to see if everything looks as expected for the parameters, you can try it from cloud code to see if it works

it looks like others had a similar error with parse server:

OK I will try with cloud code first.

Hi cryptokid,

I tried with cloud functions and got same error. I though cloud functions not cause in this case;

What is ‘protectedFields’

 TypeError: Cannot read properties of undefined (reading 'protectedFields')

you can try to read more here

it works with other tables?

is the user authenticated or now when you try that?

if I change to tables User is OK. Tables User automatically created.
I create manually table Transactions by MongoDB Compass

I created Transaction from client tool MongoDB Compass.
How to sync or tell Moralis I created new tables ?

you can try to install parse dashboard for parse server, a similar interface with the database dashboard that you see for moralis server and try to create the table from there

you can also create the table directly from code, similar to how you make the query

I install Prase Dashboard and worked.
thank you :slight_smile:

1 Like

I was also facing this issue for the past 2 days. There is no resource about this in the Moralis Documentation.
A suggestion- Please provide proper steps and things to keep in mind to migrate Cloud Code to a Self-Hosted Moralis server. Also, earlier cloud code was written in JavaScript, but now your tutorials require us to convert all the cloud code from JavaScript to TypeScript. Please make a tutorial to create a self-hosted moralis server using javascript

Also, earlier cloud code was written in JavaScript, but now your tutorials require us to convert all the cloud code from JavaScript to TypeScript

For cloud code, it is not that different. You will need to switch Moralis to Parse. If you get stuck with types, you can just use any if needed.

But if you’re a developer, it is a good idea to become familiar with TypeScript in general.

Change Moralis to Parse and done.

Moralis.Cloud.define('getRamdom4User', async (request) => {
  const query = new Moralis.Query('User');
  query.descending('createdAt').limit(4);
  const results = await query.find({useMasterKey: true});
  return results;
});

to

Parse.Cloud.define('getRamdom4User', async (request) => {
  const query = new Moralis.Query('User');
  query.descending('createdAt').limit(4);
  const results = await query.find({useMasterKey: true});
  return results;
});

Thank you for this. Also, can you guys tell me how to make Sendgrid work to send emails from the self-hosted server?

No diff when u change to self-host

My code still working

const res = await fetch('/api/sendgrid', {
        body: JSON.stringify({
          email: email,
          fullname: fullname,
          message: message,
        }),
        headers: {
          'Content-Type': 'application/json',
        },
        method: 'POST',
      });

I call my api for send email

1 Like