Sign In Register

How can we help you today?

Start a new topic
Answered

Use predefinded const attributes names within a module to query with NoSQL

Hi all,


is it possible to use const attributes - which are declared in a seperate module - in CloudCode to do searches with NoSQL?


See the following example:



CloudCode Module [SOME_MODULE]

const SOME_ATTR = "some_attr";
const SOME_ATTR2 = "some_attr_2";

 

CloudCode Event [SOME_EVENT]

require("SOME_MODULE");
Spark.runtimeCollection(SOME_ATTR).find({SOME_ATTR2 : Spark.getPlayer().getPlayerId()});

 

The use of SOME_ATTR works great but within the find-method I get zero results (if I use hard coded string instead it works).


Do you have any advice?

 

 


Best Answer

Hi Artem,


If you do something like this it should work:


require("SOME_MODULE");

var query = {};

query[SOME_ATTR2] = Spark.getPlayer().getPlayerId();

Spark.runtimeCollection(SOME_ATTR).find(query);


Kind regards,


Jonathan.

1 Comment

Answer

Hi Artem,


If you do something like this it should work:


require("SOME_MODULE");

var query = {};

query[SOME_ATTR2] = Spark.getPlayer().getPlayerId();

Spark.runtimeCollection(SOME_ATTR).find(query);


Kind regards,


Jonathan.

Login to post a comment