Dates not working within bulk methods

Dates are currently not working with bulk methods. YNikolasKS asked me to post the issue here to fix it later.
Thread here: https://discord.com/channels/819584798443569182/920741902536544346/939200263854641232

Tried to upload a date (just a classic new Date() stored in a variable) and I got this (see 3rd image attached).
Then I removed the column in my db (to see if type scheme would change), so the bulk passed without schema mismatch and in my db the column was typed as object (see 1st image attached).
More interesting when I double clicked on the “checkedAt” value and then clicked away, which triggers a saved in the Moralis interface, the client prompted an error saying I was passing a Date instead of an object (see 2nd image attached).

2nd 3rd

can you give a simple code example that replicates this problem?

I think that someone in the past had a similar problem and found this workaround:

I have to modify the type in _SCHEMA to object
then insert datetime
then switch the type back to date on _SCHEMA

Hey,

Just with something as basic as that:

Moralis.Cloud.define('testBulkDate', async () => {
  const now = new Date();
  await Moralis.bulkWrite('testBulkDate', [{ update: { now } }], {
    useMasterKey: true,
  });
  return 'done';
});

As you can see it creates an object typed field

I don’t really understand the workaround, can you elaborate, please?

The workaround requires to connect directly to db, but you should need to do that.

I think the issue originates directly from the moralis server bulk method code base right?

I don’t know exactly where from is the issue, I guess that you are already using latest version of the server too

It’s on the cloud functions so I guess yes :frowning:

I mean your Moralis Server, to be latest version

Is there any way to collaborate on the codebase, is there a github?

there is GitHub for SDK: https://github.com/MoralisWeb3/Moralis-JS-SDK
but not yet for the server part

@SachaH, I’ll get back to you later today about this problem

1 Like

@SachaH, from my tests I got into similar problems with the code that you provided.

I don’t know yet the solution.

Ok I switched to timestamps for now!

2 Likes