You are not logged in.
Pages: 1
TList<> is not supported as published property of TSQLRecord.
Okay.
Also I don't undestand why you are making one-to-one ORM relationship with MongoDB.
Shoud I not do that? What is the best approach to work with MongoDB?
I new to the mORMot Framework and MongoDB.
Just define a Localtion: variant field in your TAccountGeo class, and work with it.
Currently I'm using TDocVariant and define my fields. I'm also able to save my documents.
But when I try to update my document I'm struggling.
I can load my document with FindDoc() but I'm not able to update values.
I tried those examples from Direct MongoDB database access
var
LDoc : Variant;
begin
...
doc := Coll.FindDoc('{userid:?}',[userid]);
The result is a variant array in your examples you retrieved a document like this:
doc := Coll.FindDoc('{_id:?}',[5]);
And access values like:
doc.Name := 'New Name';
Which is not working for me, e.g. when I try to acces doc._id.
Hi,
I'm currently exploring MongoDB and the $geoNear functionality.
For studies I've read this documentation: Find Restaurants with Geospatial Queries
When I try this statement on my MongoDB (using Compass) with the exported data from the tutorial above everything is fine.
{
$geoNear:
{
near:{type:"Point",coordinates:[-73.99279,40.719296]},
maxDistance: 100,
distanceField: "dist.calculated",
includeLocs: "dist.location",
num: 5,
spherical: true
}
}
I also was able to retrieve thos data within my MVC Server.
But currently I'm not able to reconstruct this data structur with a defined TSQLRecord.
TMyLocation = class(TSQLRecord)
FType: RawUTF8;
FCoordinates: TList<Double>;
published
property Coordinates: TList<Double> read FCoordinates write FCoordinates;
property &Type: RawUTF8 read FType write FType;
end;
TAccountGeo = class(TSQLRecord)
private
FUserID: TID;
FLocation: TMyLocation;
published
property UserID: TID read FUserID write FUserID;
property Location: TMyLocation read FLocation write FLocation;
end;
As seen in this image data example from mongodb
my structure significantly divers -> my generated content
Thanks for you help.
I tried your advice and it worked well until I set the OnlyJSONRequests option true.
I need to have all clients to send JSON only so how could I realize that?
Also I noticed that my Delphiclient (which is using the interfaces) sends request like "Account.Login" instead of "Account/Login".
Can I disable this behavior?
Also I tried to use the JWTForUnauthenticatedRequest but I didn't figure out how to omit auth check for some functions like Account/Register and Account/Login
where no JWT is available.
Sorry for bothering you.
Thank you I'll try that.
And thank you for uploading the EKON example.
Thank you.
My Interface is defined as:
IAccount = interface(IInvokable)
...
function UploadPicture(const sortid: Integer; picture: TSQLRawBlob): Boolean;
end;
So the new code is implemented like this:
function TDfXAccount.UploadPicture(const sortid: Integer; picture:
TSQLRawBlob): Boolean;
At least I need one id (sortid) for this function call. Is there a way to keep this parameter?
Hi,
I'm trying to upload Images from a client to a service vice versa.
I'm using the MVC so there's an interface defined which is shared by the service and the client.
I tried to send a image from the client like this (for testing purpose):
varvar
LPicture : TSynPicture;
LIntf : IAccount;
LRawBlob : TSQLRawBlob;
LRawBytes : RawByteString;
begin
...
try
LPicture := TSynPicture.Create;
LPicture.LoadFromFile(OpenDialog1.FileName);
if LPicture.Empty then
begin
Exit;
end;
SaveAsRawByteString(LPicture, LRawBytes, gptPNG, 80, 300);
LRawBlob := BlobToTSQLRawBlob(LRawBytes);
if FClient.Services['Account'].Get(LIntf) then
begin
LIntf.UploadPicture(1, LRawBlob, 1);
end;
finally
FreeAndNil(LPicture);
end;
I do receive the LRawBlob field at my service but the bytstream is corrupte I think I need to encode the stream as Base64.
So here's my question:
If I have to manually encode the LRawBytes as Base64 wouldn't it be much easier to use RawUTF8 instead of TSQLRawBlob or do I miss something and there's some magic I could use?
P.S.: @ab: Greetings from the EKON22 I'm still missing your EKON example code.
Pages: 1