You are not logged in.
Pages: 1
Hello Again ,
i have another problem with the function GetJSONValues()
TSQLORM = class(TSQLRecord)
private
fid: RawUTF8;
fx_koordinate,fy_koordinate: RawUTF8;
fkgs22: string;
fhausid: RawUTF8;
fhh22: RawUTF8;
fjsn_01: RawUTF8 ;
fdsh_02: RawUTF8 ;
fjkn_03: RawUTF8 ;
fjkh_04: RawUTF8 ;
fjpm_05: RawUTF8 ;
fmsn_06: RawUTF8 ;
fdkn_07: RawUTF8 ;
fmfh_08: RawUTF8 ;
fdfm_09: RawUTF8 ;
fmkh_10: RawUTF8 ;
fmph_11: RawUTF8 ;
fzon_12: RawUTF8 ;
fson_13: RawUTF8 ;
fsph_14: RawUTF8 ;
fgeom: RawUTF8 ;
published
property kgs22: string read fkgs22 write fkgs22 stored AS_UNIQUE;
property hausid: RawUTF8 read fhausid write fhausid;
property hh22: RawUTF8 read fhh22 write fhh22;
property JSN_01: RawUTF8 read fjsn_01 write fjsn_01;
property DSH_02: RawUTF8 read fdsh_02 write fdsh_02;
property JKN_03: RawUTF8 read fjkn_03 write fjkn_03;
property JKH_04: RawUTF8 read fjkh_04 write fjkh_04;
property JMP_05: RawUTF8 read fjpm_05 write fjpm_05;
property MSN_06: RawUTF8 read fmsn_06 write fmsn_06;
property DKN_07: RawUTF8 read fdkn_07 write fdkn_07;
property MFH_08: RawUTF8 read fmfh_08 write fmfh_08;
property DFM_09: RawUTF8 read fdfm_09 write fdfm_09;
property MKH_10: RawUTF8 read fmkh_10 write fmkh_10;
property MPH_11: RawUTF8 read fmph_11 write fmph_11;
property ZON_12: RawUTF8 read fzon_12 write fzon_12;
property SON_13: RawUTF8 read fson_13 write fson_13;
property SPH_14: RawUTF8 read fsph_14 write fsph_14;
end;
this is how i define my record, and this i used in my function
Model := TSQLModel.Create([TSQLORM]);
Client := TSQLRestClientDB.Create(Model,nil,':memory:',TSQLRestServerDB);
if StaticMongoDBRegister(TSQLORM,Client.Server,fDB,'kgs22')=nil then
raise Exception.Create('Error');
R := TSQLORM.Create;
Client.Retrieve('hausid = 5797471', R);
But i get an Exception like
TSQLRestStorageMongoDB.GetJSONValues(TSQLORM): column count concern in row 17<>18'
i dont know why?
the document in my mongodb is this:
{
"_id" : ObjectId("54660a144c79e2c5b12fe321"),
"kgs22" : "0531400011000001000300",
"hausid" : 5797471,
"x_koordinate" : 50.7385620117187,
"y_koordinate" : 7.0974899291992,
"hh22" : 0,
"JSN_01" : "",
"DSH_02" : "",
"JKN_03" : "",
"JKH_04" : "",
"JPM_05" : "",
"MSN_06" : "",
"DKN_07" : "",
"MFH_08" : "",
"DFM_09" : "",
"MKH_10" : "",
"MPH_11" : "",
"ZON_12" : "",
"SON_13" : "",
"SPH_14" : "",
"geom" : "POINT(790088.964828841 6575178.01401502)"
}
do i need to define ID field?
Edit:
line 765:
while (row.Item.Data.DocList^<>byte(betEof)) and (col<colCount) and
item[col].FromNext(row.Item.Data.DocList) do
inc(col);
if col<>colCount then
on mormotMongoDb shows me different column numbers , so must be something to do with me definitions of the record
Last edited by mynotos (2014-11-25 13:32:41)
Offline
oH ok , i understand ok thank you
Offline
Hey AB,
i tried with adding an Integer Value into my document and setup as primary but i get the same message column concern 18<>19
if you can help me with an example , would be nice..
Thank you
Offline
I thought i need to define the record to fetch the data from MongoDB to directly access it , i want to display this Record,(Table) in my cxGrid
if i run Coll.FindDocs('{kgs22: /^10/}',[],fValues,null); as Example
and do
jsonArray:= VariantDynArrayToJSON(fValues);
DataSource1.DataSet := JSONToDataSet(self, jsonArray);
to fil my Dataset i can display me all Data correctly but cannot modify on the fly, this is reason why i tried the ORM way , may this is not correct
Edit:
found out
i miss typed one defintion of my property
Last edited by mynotos (2014-11-27 10:10:16)
Offline
Note that you can now use directly
DataSource1.DataSet := ToDataSet(fValues);
and avoid the JSON translation step.
OK so I understand your POV.
But you have to define the TSQLRecord to match the existing document layout...
Or just simply use a projection to retrieve only the needed fields.
Offline
Yes correct i did it now but i have some id conversion problem
i think its because of the init32 fID
like
Client.Retrieve('kgs22 = '+chr(39)+'0832702300000100000200'+chr(39)+'', R);
R.kgid := '1';
(Client.Server.StaticDataServer[TSQLORM] as TSQLRestStorageMongoDB).Update(R);
R has the id = 54758
but the document in the mongodb has this object id
"_id" : ObjectId("54758b55d499de70714dae2e"),
so this b55d499de70714dae2e is missing
and the update command dont work properly. Any Idea ?
Offline
but i can give him like an WHERE clause to update the document ?
Because the update only use the id as reference
Offline
Pages: 1