#1 2021-05-28 07:16:28

nothratal
Member
Registered: 2021-05-27
Posts: 1

Trying to understand mORMot’s server units and its concepts

Hello together,

I’m new to mORMot and I hoped I can get here some initial input to get started. I must admit that I just started recently learning Pascal (FreePascal in my case) too. mORMot’s documentation is very comprehensive, in a good way of course, so I was able to get into the core concepts. In other languages I used microservice frameworks, they were completely different in their concepts (configuration over convention), but I still try to make some comparisons.
I think the ORM-part is pretty clear for me, how it can be used, that URL's and rest endpoints are generated relative to the convention.

So, the questions I have so far, are:

1. What are the differences between TSQLHttpServer, THttpServer, and THttpApiServer? As I understood the TSQLHttpServer is used in an ORM context. But what about the other two? Technically there isn't a difference between a server used for API's or for web content.

2. Can I use the ORM-part without any database? Like working with a cache because technically nothing has to be persistent anyway? Can I use mORMot without the TSQLModel’s, so just the technical layer?

3. mORMot seems very elegantly handling databases. Coming from other languages & frameworks: How can I set up a simple HTTP server, just returning for example a simple hello world string instead of an automatically generated JSON? I found Units in SynCrtSock (e.g. THttpServer), but I didn’t get it run or found an example.

4. I know that mORMot2 is already in development. As I don’t really write code that has to run in production (or running anywhere besides my own personal laptop tongue ), does it make more sense to start learning immediately v2?

Thanks in advance!

Offline

#2 2021-05-28 07:50:12

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,350
Website

Re: Trying to understand mORMot’s server units and its concepts

0. Welcome.

1. THttpServer, and THttpApiServer are the HTTP server themselves, which is used by TSQLHttpServer to publish one or several TSQLRestServer instances.

2. Yes, just use a TSQLRestServerDB with in-memory database or a TSQLRestServerFullMemory, with no table associated in the model. You will need a TSQLModel instance for the URI routing (for the /root/.... in the URI), but if you associate no table in the model, then no ORM is involved. This is in fact how a public API should be defined.

3. Please see the samples. And read the FAQ of the documentation.

4. You can learn and use mORMot 2 for a new project. It is almost production ready, but if you find any bug, please report it in this forum, and we will fix it ASAP.

Offline

Board footer

Powered by FluxBB