Sign In Register

How can we help you today?

Start a new topic

cant get document id in collection

I have a collection of cards and in my came I copy some of them to the players' script data in an array.


When trying to access the ids of those cards via "cardVariable._id.$oid" I get this error

Access to Java class "org.bson.types.ObjectId" is prohibited.

 When viewing the script data in the NoSql viewer I can see the fields are there.

Do I have to rename these fields when saving them to the array to access them again? Not sure what I'm doing wrong.


Thanks for your time!


Hi,


Can you describe more how you are adding the documents to the players scriptData? Would you mind showing us an example of these documents as they exist in the array?


If the cards have been loaded as JSON documents in Cloud Code then there should be no issues regarding access.


Let us know more and we'll get back to you


-Pádraig

These documents go through a 3 step process.

  1. On creation of the game, I query the collection of card documents for cards that meet the criteria of the game and save them to my challenge's private data call cardBank.
  2. Each player has an array called "hand" in their scriptData. When the game enters a new round, we take a document from the cardBank and add one to each players hand while removing it from the bank. this is where when I view the challenge I can see in both the bank and the players hands that { "_id" : { "$oid" : "someIdHere" } } is still visible
  3. When a combo of cards are played, I submit them to another collection call gameHistory. We don't allow duplicates, so when they are submitted, they have an element called combinedIds which I use to check for duplicates before submitting.

This is where I run into the error; when I try to access the ids of the cards.

I'm gonna try adding a cachedId field to the cards when dealt. Maybe that will be a workaround for now.

Ok so I actually got the id by just doing it via ._id but now I've run into a new error

Write failed with error code 17280 and error message 'Btree::insert: key too large to index...

 So I guess you can mark this as answer and I've opened a new thread here

Login to post a comment