#1 Re: mORMot 2 » Where do I start? » 2024-09-07 12:39:49

Thank you, @Thomas.
I’m trying my best to read the answers carefully, but since English isn’t my native language, I don’t fully understand everything, and sometimes I even explain things poorly.
I apologize for that. I will try harder and ask fewer questions.

#2 Re: mORMot 2 » Where do I start? » 2024-09-07 07:03:13

Thanks, @igors233.
I’m using SQL Server 2008 for the database.
I’m also using JWT and username/password for authentication.
I have an existing API written with HORSE, and I wanted to rewrite it with mORMot.
Additionally, I want to use the ORM feature of the mORMot framework in this rewrite (I have prior experience using TMS Aurelius).
The first challenge for me was understanding the different servers in mORMot, as I wasn’t sure which server is for what.
The second challenge was connecting it to SQL Server.
I haven’t yet tried JWT and authentication.
Regarding the servers, I realized that when I use TRestServerDB, the user or client can easily access the tables. Authentication might prevent this access, but from what I’ve studied, it doesn’t seem to check the access details. For example, imagine I have a "status" field that marks records as deleted (without physically deleting them). In the method for listing data, I don’t send these records, but since the client has access to the table through ORM, they can retrieve those records.
Also, when I use TRestServerFullMemory, I no longer have access to the ORM.

#3 Re: mORMot 2 » Where do I start? » 2024-09-03 10:34:44

When I switch from TRestServerDB to TRestServerFullMemory, how do I access the database?
Do I have to abandon ORM in this case and revert to the old method of database access?

#4 Re: mORMot 2 » Where do I start? » 2024-09-02 11:10:28

I think I was a bit confused, but I understand now. smile

#5 Re: mORMot 2 » Where do I start? » 2024-08-31 13:20:29

No, I don't want to keep the tables in the original TRestServer model.

#6 Re: mORMot 2 » Where do I start? » 2024-08-31 12:42:09

You have run so many marmot tests and everything is clear to you. It's not that clear to me.
I've modified the server by setting

HttpServer := TRestHttpServer.Create(HttpPort, [], '+', useHttpApiRegisteringURI,4);

, but my Delphi client can no longer connect to it.
I reverted the previous command to its original state and made changes to the service.
I modified the class from 'TProductServer = class(TRestServerDB)' to 'TProductServer = class(TRestServer)'.
However, I'm getting an access violation error at the line 'ServiceDefine(TProductService, [IProductService], sicShared);'
I really don't know where to delete the model from the server.

#7 Re: mORMot 2 » Where do I start? » 2024-08-31 11:43:37

I've been unable to locate a solution to prevent direct access to the ORM.
It would be convenient if the server offered a method named AllowDirectAccess. :rolleyes

#8 Re: mORMot 2 » New AI assistant to help with mORMot » 2024-08-31 11:22:16

It was interesting talking to them, but it didn't help me.

#9 Re: mORMot 2 » Where do I start? » 2024-08-20 07:45:31

Kabiri wrote:

Thank you.
I changed the interface name.
It's giving the error:
Project TestServer.exe raised exception class EHttpApiServer with message 'HttpSetServiceConfiguration failed: ERROR_ACCESS_DENIED (5)'.
But the database and table are created. (I also added the command ProductServer.Server.CreateMissingTables;).

Is this error a known occurrence?
What steps should be taken to rectify this error?

---Edit
I have also successfully modified the list method.

Is this the right and proper way to do this?

function TProductService.List(var AProduct: TProductParam): RawJson;
var
  Sql: RawUtf8;
begin
  Sql := 'select * from Product';
  Result := TRestServerDB(Self.Server).DB.ExecuteJson(Sql, True);
end;

How do I disable ORM for the client?
Currently, there are commands like :
http://127.0.0.1:8080/root/Product
http://127.0.0.1:8080/root/Product/1
are returning records without any filtering or validation

#10 Re: mORMot 2 » I want use ORM very much but MORMOT are some restrictions » 2024-08-19 12:26:37

I use SQL but I never use foreign keys. I always manage table relationships myself. I think foreign keys are more of a hindrance.

#11 Re: mORMot 2 » Where do I start? » 2024-08-19 09:47:12

I think my way of categorizing units into Controller and DAC is not very suitable for Mormot.
I should choose a different structure for categorizing files in Mormot.
Do you categorize your files in a specific way?
My next question is how to implement the List method to return the list of desired records to the client?

Thanks

#12 Re: mORMot 2 » Where do I start? » 2024-08-18 17:58:54

Thank you.
I changed the interface name.
It's giving the error:
Project TestServer.exe raised exception class EHttpApiServer with message 'HttpSetServiceConfiguration failed: ERROR_ACCESS_DENIED (5)'.
But the database and table are created. (I also added the command ProductServer.Server.CreateMissingTables;).

#13 Re: mORMot 2 » Where do I start? » 2024-08-18 06:32:24

What is the reason for the following error?
Project TestServer.exe raised exception class EServiceException with message 'TServiceFactoryServer.Create: IProduct routing name is already used by a Product SQL table name'.

My test Project source
https://mega.nz/file/d5RTDB5A#f-mBchZj4 … a826ZtybbA

I haven't assigned the model to TRestHttpServer.Create yet, but the problem doesn't originate from there.

#14 Re: mORMot 2 » Where do I start? » 2024-08-17 11:33:35

I finished reading BeDelphi2014 today.
There are still some things that are unclear to me.
My first question is:
Has the syndb unit been removed from mormot2?

#15 Re: mORMot 2 » Where do I start? » 2024-08-14 11:50:10

In the examples, I only saw connections to SQLite. What should I do for MSSQLServer?
Which units should I add?
Previously, when accessing the database,
I created a connection and then closed it after retrieving the data. (In the events related to creating and destroying the class) And apparently here, when the server is running, the connection is created and remains open until the end of the server.

#16 Re: mORMot 2 » Where do I start? » 2024-08-13 17:40:27

Well, that's right. I hadn't thought about the FP.

#17 Re: mORMot 2 » Where do I start? » 2024-08-13 17:01:37

In the unit 'mormot.core.variants', the unit 'mormot.core.base' is called,
which in turn calls 'variants'. However, the IDE mistakenly identifies it as 'mormot.core.variants'.
While this is indeed an IDE error (Or an unintentional setting in the IDE) , the easiest way to prevent this is to use 'system.variants' instead.

#18 Re: mORMot 2 » Where do I start? » 2024-08-13 13:51:34

@ab
I downloaded the new version of mormot2 yesterday.
In the mormot.core.base unit at line 36, the unit variants should be changed to system.variants.
Because it's giving a Circular unit reference to 'variants' error.
(Delphi 12.1)

#19 Re: mORMot 2 » Where do I start? » 2024-08-12 16:42:45

Thank you. I will try it

#20 Re: mORMot 2 » Where do I start? » 2024-08-12 15:35:37

I'm not sure I understand correctly.
Do you mean I should write an application server on a server and have an API connect to it as a client, retrieve database information, and then act as a server itself to send the data to the client (user side)?

#21 Re: mORMot 2 » Where do I start? » 2024-08-12 14:58:01

Márcio Baroni wrote:

I've been using Mormot for a long time and it was really difficult at first.
If I can give one piece of advice, don't mix the ORM layer with the API layer.
Create ORM classes just to interact with the database.
Create another layer of classes (DTO) for your api or business rules...
With your DTO you can return whatever you want in your api without any relation to ORM, making it much cleaner.

Thank you for your explanation.
I generally prefer to keep the ORM and API layers separate. I'm not sure if this would cause a performance decrease.
I've been busy with other things for a while, but now I'm back to learning about Mormot. I want to create methods both with and without Models on a single server, and connect to it using a client.
I hope this isn't too difficult and I'm not bothering anyone.

#22 Re: mORMot 2 » Where do I start? » 2024-07-04 11:54:05

Thanks @ab
Thanks @edwinsn
Thanks @rdevine

I think I'll be busy with this for a few days.
The question that's on my mind is whether it's possible to have multiple ORM models, multiple JSON outputs from the database, and non-model methods in a single API.

#23 Re: mORMot 2 » Where do I start? » 2024-07-04 06:29:22

Thanks @edwinsn smile
I am determined to learn mormot2. I can use it with the help of examples, but I wanted to understand how it works. I have a lot of questions on my mind and I hope to find the answers soon.

It would be great if this forum had a "thanks" button for posts.

#24 Re: mORMot 2 » Where do I start? » 2024-07-04 06:22:53

lfyey121 wrote:

Orm model can have no objects;

I understand. So in any case, the model must be created, but the model can be empty and not contain any objects.
Thanks

#25 Re: mORMot 2 » Where do I start? » 2024-07-03 21:45:46

tbo wrote:

Why is this a problem?

With best regards
Thomas

That's not the problem.The problem is how to do it.

APIs can generate different types of outputs.
For example:

  • A method that simply returns a number as the API version.

  • A simple method (like ping) that returns a simple value (for testing connectivity).

  • Up to complex methods that return a record or records from a database.

  • Or even files or streams.

Therefore, an API needs to be able to access all types of methods.

#26 Re: mORMot 2 » Where do I start? » 2024-07-03 17:26:48

I reviewed the mormot2 examples. In the examples, everyone uses the model. sad

#27 Re: mORMot 2 » Where do I start? » 2024-07-03 07:20:38

I've looked through the v1 documentation as much as I can, but I'm still not sure how to connect to the TRestServerFullMemory server for communication on the client side when I'm not using a model and orm.
I used TRestHttpClient and set the model parameter to nil. But I get an accessviolation error in the ServiceDefine instruction.

#28 Re: mORMot 2 » Where do I start? » 2024-07-01 13:08:27

Thank you.  I fully understood how to use the interface without using orm.
I have a problem with the client. If I don't understand, I will ask.

#29 Re: mORMot 2 » Where do I start? » 2024-06-30 17:58:31

Thank you.
I have created a new record for the output, but the JSON output contains both the input record and the record I defined for the output. What can I do to prevent the input from being sent in the output?
Also, how can I test this with Postman?
I tried several URLs in my Postman request, but the inputs are not being received.

get : http://127.0.0.1:8080/api/Calculator.Add/?Data={N1:1,N2:2}
post : http://127.0.0.1:8080/api/Calculator.Add
body-raw : {Data={"N1":1,"N2":2}}

#30 Re: mORMot 2 » Where do I start? » 2024-06-29 13:03:52

Based on what I have learned, I wanted to create an interface-based server.
I do not want to use ORM on my server. That's why I did not create a class for orm and data.
The program stops with an error and I don't understand why.

---I have removed the code to comply with the rules.

#31 Re: mORMot 2 » Where do I start? » 2024-06-27 08:05:24

Thank you for your responses, friends.

I understand that there are three ways to work with mORMot:
1 - The REST ORM
2 - Methods-based services
3 - Interface-based services

I also didn't understand how to create multiple routes for my API. What I did was look for the route name in the URL in the OnRequest event and execute a function.

I also tried to use the route and router properties in the following way, but it didn't work:
fHttpServer.Rout.Get('Ping',Ping);
fHttpServer.Router.Get('Ping',Ping);

#32 Re: mORMot 2 » Where do I start? » 2024-06-25 10:43:55

Thanks for your guidance, friends.

I know enough to build a simple server and use a websocket with it.
I'm looking for the basic concepts and principles to have a good understanding of its structure in order to create a large system.
I've already written five large APIs with Horse. Recently, a friend of mine mentioned that mormot v2 has changed a lot. It is very fast. That's why I decided to write the new API with mormot. But I have a superficial understanding of it. I would like to know how to get the most out of it.

#33 mORMot 2 » Where do I start? » 2024-06-24 08:51:57

Kabiri
Replies: 72

Hi,
The main point I'd like to make is that there is no documentation or guide for learning the basics of this framework.
There are only references from the website to GitHub and back again. In the end, you can only look at the sample programs!
It's very frustrating that there is no explanation of how to work with this framework from the ground up.

Board footer

Powered by FluxBB