You are not logged in.
Hi AB.
I'm playing with MongoDB and replicaset.
Via ORM write in Db without problems, but it always comes out the exception: unknow type 17 (betTimeStamp)
I found where to make the patch, but I do not know what to enter.
procedures TBSONElement.AddMongoJSON (W: TTextWriter; Mode: TMongoJSONMode);
bin label, regex;
begin
Kind of homes
betFloat:
W.Add (PDouble (Element) ^);
betString, betJS, betDeprecatedSymbol: begin
W.Add ('"');
W.AddJSONEscape (data.text, Data.TextLen);
W.Add ('"');
end;
betDoc, betArray:
BSONListToJSON (Data.DocList, Kind, W, Mode);
betObjectID: begin
W.AddShort (BSON_JSON_OBJECTID [false, Mode]);
W.AddBinToHex (Element, SizeOf (TBSONObjectID));
W.AddShort (BSON_JSON_OBJECTID [true, Mode]);
end;
betTimeStamp: begin
// ***************************************************************** here
end;
Offline
Temporary solution: (ignore it)
add two line:
procedure TBSONElement.AddMongoJSON(W: TTextWriter; Mode: TMongoJSONMode);
label bin,regex;
begin
case Kind of
betFloat:
W.Add(PDouble(Element)^);
betString, betJS, betDeprecatedSymbol: begin
W.Add('"');
W.AddJSONEscape(Data.Text,Data.TextLen);
W.Add('"');
end;
betDoc, betArray:
BSONListToJSON(Data.DocList,Kind,W,Mode);
betObjectID: begin
W.AddShort(BSON_JSON_OBJECTID[false,Mode]);
W.AddBinToHex(Element,SizeOf(TBSONObjectID));
W.AddShort(BSON_JSON_OBJECTID[true,Mode]);
end;
betDeprecatedUndefined:
W.AddShort(BSON_JSON_UNDEFINED[Mode=modMongoShell]);
betBinary:
case Mode of
modNoMongo:
W.WrBase64(Data.Blob,Data.BlobLen,true);
modMongoStrict: begin
W.AddShort(BSON_JSON_BINARY[false,false]);
W.WrBase64(Data.Blob,Data.BlobLen,false);
W.AddShort(BSON_JSON_BINARY[false,true]);
W.AddBinToHex(@Data.BlobSubType,1);
W.AddShort('"}');
end;
modMongoShell: begin
W.AddShort(BSON_JSON_BINARY[true,false]);
W.AddBinToHex(@Data.BlobSubType,1);
W.AddShort(BSON_JSON_BINARY[true,true]);
W.WrBase64(Data.Blob,Data.BlobLen,false);
W.AddShort('")');
end;
end;
betRegEx:
case Mode of
modNoMongo:
bin:W.WrBase64(Element,ElementBytes,true);
modMongoStrict:
goto regex;
modMongoShell:
if (PosChar(Data.RegEx,'/')=nil) and
(PosChar(Data.RegExOptions,'/')=nil) then begin
W.Add('/');
W.AddNoJSONEscape(Data.RegEx,Data.RegExLen);
W.Add('/');
W.AddNoJSONEscape(Data.RegExOptions,Data.RegExOptionsLen);
end else begin
regex:W.AddShort(BSON_JSON_REGEX[0]);
W.AddJSONEscape(Data.RegEx,Data.RegExLen);
W.AddShort(BSON_JSON_REGEX[1]);
W.AddJSONEscape(Data.RegExOptions,Data.RegExOptionsLen);
W.AddShort(BSON_JSON_REGEX[2]);
end;
end;
betDeprecatedDbptr:
goto bin; // no specific JSON construct for this deprecated item
betJSScope:
goto bin; // no specific JSON construct for this item yet
betTimeStamp: // <<----------------------------------------------------add this
goto bin; // <<----------------------------------------------------add this
betBoolean:
W.AddString(JSON_BOOLEAN[PBoolean(Element)^]);
betDateTime: begin
W.AddShort(BSON_JSON_DATE[Mode,false]);
W.AddDateTime(UnixMSTimeToDateTime(PInt64(Element)^));
W.AddShort(BSON_JSON_DATE[Mode,true]);
end;
betNull:
W.AddShort('null');
betInt32:
W.Add(PInteger(Element)^);
betInt64:
W.Add(PInt64(Element)^);
else
if Kind=betMinKey then
W.AddShort(BSON_JSON_MINKEY[Mode=modMongoShell]) else
if Kind=betMaxKey then
W.AddShort(BSON_JSON_MAXKEY[Mode=modMongoShell]) else
raise EBSONException.CreateFmt('Unexpected BSON element of type %d',[ord(Kind)]);
end;
end;
Offline
Does http://synopse.info/fossil/info/a1dcebf2f1 work for you?
Offline
no...
look at optime and electionTime
looks like a base64 ...
this from delphi debugger: "optime":"ï¿°CgAAADYnK1Q="
ResutUTF8: {"set":"rs0",
"date":"2014-10-01T19:47:42",
"myState":1,
"members":[{"_id":0,
"name":"WIN-G1V0GLAHABK:27019",
"health":1,
"state":2,
"stateStr":"SECONDARY",
"uptime":689,
"optime":"CgAAADYnK1Q=",
"optimeDate":"2014-09-30T21:57:10",
"lastHeartbeat":"2014-10-01T19:47:40",
"lastHeartbeatRecv":"2014-10-01T19:47:41",
"pingMs":0,
"syncingTo":"192.168.172.130:27020"},
{"_id":1,
"name":"192.168.172.130:27018",
"health":1,
"state":2,
"stateStr":"SECONDARY",
"uptime":689,
"optime":"CgAAADYnK1Q=",
"optimeDate":"2014-09-30T21:57:10",
"lastHeartbeat":"2014-10-01T19:47:41",
"lastHeartbeatRecv":"2014-10-01T19:47:41",
"pingMs":1,
"syncingTo":"192.168.172.130:27020"},
{"_id":2,
"name":"192.168.172.130:27020",
"health":1,
"state":1,
"stateStr":"PRIMARY",
"uptime":690,
"optime":"CgAAADYnK1Q=",
"optimeDate":"2014-09-30T21:57:10",
"electionTime":"AQAAALNXLFQ=",
"electionDate":"2014-10-01T19:36:19",
"self":true}],
"ok":1}
Offline
but: >>>>ï¿°C<<<<< ?
Offline
I got it.
Now you will write the changes to auto decode it?
Offline
What do you do with this value?
Getting and updating some documents which contain this value?
Are you sending back the timestamp value to the MongoDB Server? AFAIK those values are for MongoDB internal use only.
We first started to implement the TimeStamp() syntax, but it sounded like not needed since the value was for internal use only.
Offline
Personally I only read them.
In the first post you can see the result of:
resUTF8: = fdb.RunCommand ('replSetGetStatus', res);
Offline