There was the problem with whitelisting IPs, since I have a server that rotates IP addresses, so the automatically regenerating backend will at some point not be able to connect to the database since I canβt whitelist a DNS address.
can you give a minimal complete code example with .aggregate that I could also test if it works?
import Moralis from `moralis/node`
const testMoralis = async () => {
Moralis.start({
appId: ...
serverUrl: ...
masterKey: ...
})
const pipeline = [
{match: {someField: "fieldValue"}}
]
const result = await (new Moralis.Query("SomeCollection")).aggregate(pipeline, {useMasterKey: true})
}
Something like this
this works fine for me:
x = async () => {
const Moralis = require('moralis/node')
console.log(Moralis.CoreManager.get("VERSION"))
await Moralis.start({ serverUrl: "https://afasdf:2053/server", appId: "sdgasdg", masterKey: "sfgsdfg" });
const pipeline = [
{match: {username: "Gn6Px7RUd9JkiJLVTdEMD4cen"}}
]
const result = await (new Moralis.Query("User")).aggregate(pipeline, {useMasterKey: true})
console.log(result);
}
x();
1 Like
It seems that the queries I made before were all on default public fields so they never triggered this error. I had multiple Moralis initialiser definitions with different environment variables for each different test server. The masterkey was passed to the Moralis.start in this case, but it was a copy paste error from another server`s initialiser that only had the correct URL and app id.
Thanks for your help in resolving this. Much appreciated!
1 Like