[SOLVED] Error: schema mismatch for ...; expected File but got String

What I’ve got in Database:

Class_of_Items Table
Test_Class Table

What I tried:

get data of file_1 and make a Moralis.File 
get data of file_2 and make a Moralis.File 
get data of file_3 and make a Moralis.File 

await file_1.saveIPFS()
await file_2.saveIPFS()
await file_3.saveIPFS()

class.set("1st_file", file_1)
class.set("2nd_file", file_2)
class.set("3rd_file", file_3)

class.save()

It works well at a new created Test_Class (temporary table for a test)

I have checked my code several times, all File objects gets written in IPFS, :heavy_check_mark:
and together with this fact,
Also gets written in Test_Class (test table) in database very well.:heavy_check_mark:

Problem

Even the First File Object is accepted, while the file_2’s turn comes,
or if I remove file_2 from the queue, this time problem comes for the file_3,
I can’t write in that “previously-created” Class_of_Items Table

2022-04-04T12:00:48.822Z - Error: schema mismatch for Class_of_Items.2nd_file; expected File but got String
    at SchemaController.enforceFieldExists (/moralis-server/lib/Controllers/SchemaController.js:1250:15)
    at SchemaController.validateObject (/moralis-server/lib/Controllers/SchemaController.js:1391:28)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Notes

  • Class_of_Items has already got “1st_file” field and doesn’t throw error while writing in.
  • Class_of_Items has files already written in file_1 column.
  • The problem persists only for the second file (file_2 in the example) or the third one.

Again, all the file objects gets written in IPFS without a problem, I got their hashes, but only when writing in the Class_of_Items (which was previously created) table.

Makes me think, a table which has 24 columns has limits of File Objects amount…?

why do you want to save that file object in the database?

I want to keep multiple files for an NFT item data in a class, to be able to reach for the users when neeeded
(only the image will be metadata while NFT minted)

you can upload the file on IPFS and only keep the url to IPFS in the database, and maybe some extra info

Your suggestion helped a lot on that I just realized now that I missed the TYPE of my new columns were determined as FILE, instead of String, which actually gets IPFS File Path as string :sparkles:

So whoever gets that error might re-check its “data type”, if you created a column manually by hand, let’s say even for a testing purpose.

All good now. :white_check_mark:

Thank you one more time.

2 Likes