#2 mORMot 1 » How to return data as True JSON not String (Browser + mORMot Service ) » 2016-02-25 06:46:21

chowong
Replies: 2

Hi Everyone

     I have some issue about JSON data returned from mORMot Service.

I have created a service with mORMot (TCarService.GetData) and

the service is called from Browser Client (AngularJS).

Below is service code 

function TCarService.GetData(aSqlText: RawUTF8): RawUTF8;
var
  Props : TSQLDBConnectionProperties;
  res : ISQLDBRows;
begin

  Props := TOleDBMSSQL2012ConnectionProperties.Create('127.0.0.1', 'Car_DB', 'sa', 'password');

  try
    res := Props.ExecuteInlined(aSqlText, True);

    result := res.FetchAllAsJSON(True);
  finally
    Props.Free;
  end;
end;

but the returned JSON result looks like this

{"result":["[
  {\"MakeCode\":\"ALFA\"},
  {\"MakeCode\":\"ASTO\"},
  {\"MakeCode\":\"AUDI\"},
  {\"MakeCode\":\"BENT\"},
  {\"MakeCode\":\"BMW \"},
  {\"MakeCode\":\"CHER\"},
  {\"MakeCode\":\"TOYO\"},
  {\"MakeCode\":\"VOLK\"},
  {\"MakeCode\":\"VOLV\"}
]\n"]}

Is there ways to return as True JSON data not string (with FetchAllAsJSON(True)) ?

or I must remove '"', '\' , '\n'  at Client Side.

expected Result like this

{"result":
  [
    {"MakeCode":"ALFA"},
    {"MakeCode":"ASTO"},
    {"MakeCode":"AUDI"},
    {"MakeCode":"BENT"},
    {"MakeCode":"BMW"},
    {"MakeCode":"CHER"},
    {"MakeCode":"TOYO"},
    {"MakeCode":"VOLK"},
    {"MakeCode":"VOLV"}
]}

Thank you very much

#4 mORMot 1 » Reconcile Error Event (Like DataSnap) in mORMot framework? » 2016-02-04 03:05:18

chowong
Replies: 2

Hi Everyone,

   I am new to mORMot framework and I have a question about it.

Does mORMot have any feature like Reconcile Error Event (Delphi 's DataSnap)?

Ex.
   1) User A and User B retrieve the same record
 
   2) User A edits and saves the record

   3) User B edits and saves the record after User A commits transaction

   4) User B gets an error message  'Record changed by another user' and Rollback Transaction.

  I found mORMot framework is so amazing and I really want to move from DataSnap to mORMot but my boss still loves DataSnap cause it only has Reconcile Error feature!)

Thank you very much,

Chowong

Board footer

Powered by FluxBB