bulkWrite is not a function

Hello, Im trying to do a bulkWrite to my Moralis DB and I get an error saying that this function does not exist. Currently using Typescript, Vue.js and @moralis1.0.7

Screen Shot 2022-01-30 at 10.57.16 AM

async uploadDistinctItems(aMap: Map<string, string>, arbitraryString: string) {
for (let [key, value] of aMap) {
        let aUrl = "";
        let curr = {} as Record<string, string>;
        curr["1"] = arbitraryString;
        curr["2"] = key;
        curr["3"] = value[0];
        curr["4"] = value[1];
        let bulkWriteObjects = { update: curr } as Record<string,Record<string, string>>;
        this.bulkWritePayload.push(bulkWriteObjects);
        aUrl = key;
      }
     const query = new this.$moralis.Query("someDatabase");
     query.equalTo("theKeyProperty", aUrl);
     const results = await query.find();
      if (results.length == 0) {
         // eslint-disable-next-line @typescript-eslint/ban-ts-comment
         // @ts-ignore
         this.$moralis.bulkWrite("someDatabase", this.bulkWritePayload);
        }
     } 

I’ve also tried Moralis.bulkWrite(...) and I get the same error

I think that it works only in cloud code

I rewrote this as a cloud function and it worked. Thanks

1 Like