mongodb - Mongo Types NumberInt NumberLong -
using mongo java driver if insert following document:
document monday = new document() .append("counter",1) .append("model1", data1) .append("model2", data1) .append("model3", data1) .append("model4", data1);
counter have hoped have been of type numberint(). have found seems end numberlong(). have rewritten above be:
int counter = 1; document monday = new document() .append("counter",counter) .append("model1", data1) .append("model2", data1) .append("model3", data1) .append("model4", data1);
this creates numberint() sure. when update follws:
if (counter>=4){counter=1;}else{counter++;} loc = dow.concat(".").concat("counter"); collection.updateone(and(eq("topic",topic),eq("sp",settlement)), new document("$set", new document(loc,counter)));
will type stay numberint() or converted mongo majic numberlong(). issue when:
int counter = docday.getinteger("counter");
does change 1 int counter = 1; make sure mongo use numberint() rather numberlong().
what controls decision , how force numberint() within java driver.
Comments
Post a Comment