Skip to content

Commit

Permalink
Merge pull request #157 from hemedani/main
Browse files Browse the repository at this point in the history
create projection fn
  • Loading branch information
hemedani authored Apr 30, 2024
2 parents 8b6bf90 + f24ed64 commit cd79da1
Show file tree
Hide file tree
Showing 140 changed files with 320 additions and 170 deletions.
2 changes: 1 addition & 1 deletion docs/404.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/CSR_SSR_or_SSG_content.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Dynamic_structure.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Lesan_solution.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Microservice.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Penetration_Into_Depths.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Previous_methods_and_the_main_challenge.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Pure_Structure_In_Schema.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Queuing_data_changes.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Receiving_Data.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Request_processing.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Schemas.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Static_structure.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/The_InRelation_Structure_In_Schema.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/The_structure_of_OutRelation_in_the_schema.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/The_structure_of_Struct_in_the_schema.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/The_structure_of_embed_in_the_schema.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/Why_NoSQL.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/add_more_relation.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/add_relation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/add_relation_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/advanced_general_description.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/advanced_nx_config.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/aggregation_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/all_advantages_of_lesan.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/an_advanced_project.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/acts/acts_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/acts/getAct/getAct_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/acts/getActKeys/getActKeys_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/acts/getActs/getActs_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/acts/getActsKeys/getActsKeys_Fns.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/acts/getMainAct/getMainAct_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/acts/getMainActs/getMainActs_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/acts/getService/getService_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/acts/getServiceKeys/getServiceKeys_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/acts/setAct/setAct_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/acts/setService/setService_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/context/contextFns_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/context/getContextModel/addBodyToContext_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/context/getContextModel/addContext_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/context/getContextModel/addContexts_Fns.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/context/getContextModel/addReqToContext_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/context/getContextModel/getContextModel_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/context/setContext/setContext_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/generateSchema/generateSchemTypes_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/lesan_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/getCollection/getCollection_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/newModel/addRelation_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/newModel/aggregation_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/newModel/deleteOne_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/newModel/findOneAndUpdate_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/newModel/findOne_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/newModel/find_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/newModel/insertMany_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/newModel/insertOne_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/newModel/newModel_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/newModel/removeRelation_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/odm_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/odm/setDb/setDb_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/runServer/runServer_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/mainRelationsFns/getMainRelations_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/mainRelationsFns/mainRelations_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/pureFns/addPureModel_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/pureFns/getPureModelByNameAndKey_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/pureFns/getPureModel_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/pureFns/pure_Fns.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/relationFns/getRelation_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/relationFns/relation_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/schemaFns/createEmbedded_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/schemaFns/createStruct_fn.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/schemaFns/getPureOfMainRelations_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/schemaFns/getPureSchema_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/schemaFns/getSchema_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/schemaFns/getSchemasKeys_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/schemaFns/getSchemas_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/schemaFns/schemaFns_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/schemas_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/selectStructFns/checkRelation_Fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/selectStructFns/decreaseIterate_Fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/selectStructFns/fieldType_Fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/selectStructFns/selectStructFns_Fns.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/schemas/selectStructFns/selectStruct_Fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/Services/ActInp.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/Services/Acts.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/Services/Acts/Act.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/Services/Acts/Act/ActFn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/Services/Acts/Act/ActFn/TLesanBody.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/Services/Services.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/TInsertRelations.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/TInsertRelations/IRelationsFileds.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/aggregation/projection/projection.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/context.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/context/LesanContenxt.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/odm.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/schema/CheckRelation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/schema/IModel.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/schema/IPureFields.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/schema/Iterate.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/schema/RelationType.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/schema/Tschemas.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/schema/model/IMainRelation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/schema/model/IRelatedRelation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/schema/model/TRelation.html

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/api/types/types.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/delete_one_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/findOne_and_find_fn.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/find_one_and_update_functions.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/folder_structure.html

Large diffs are not rendered by default.

19 changes: 9 additions & 10 deletions docs/getting_start.html → docs/getting_started.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/insert_many_fn.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/installation.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/introduction.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/leasan_vs_graphql.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manage_replica.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/mannage_relations.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/microservice-monolithic.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/playground.html

Large diffs are not rendered by default.

70 changes: 59 additions & 11 deletions docs/print.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/remove_relation_fn.html

Large diffs are not rendered by default.

55 changes: 52 additions & 3 deletions docs/request_flow.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/runServer_(web_server_structure).html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/searchindex.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/what_is_the_relationship.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pages/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# User Guide

- [Installation](./installation.md)
- [Getting start](./getting_start.md)
- [Getting started](./getting_started.md)
- [Add relation](./add_relation.md)
- [Add more relation](./add_more_relation.md)
- [Mannage relations](./mannage_relations.md)
Expand Down
13 changes: 6 additions & 7 deletions pages/src/getting_start.md → pages/src/getting_started.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Getting start
# Getting started

I copy this simple example from [installation](./installation.md) page. We will keep this file as `mod.ts` and continue to add various models and functions to it.

Expand Down Expand Up @@ -199,7 +199,7 @@ const addCountry: ActFn = async (body) => {
```

This function receives an input called `body`, the `body` of the `request` sent from the client side is passed to it when this function is called, as a result, we have access to the information sent by users.
The request body sent from the client side should be a json like this:
The request body sent from the client side should be a `JSON` like this:

```JSON
{
Expand All @@ -222,12 +222,11 @@ The request body sent from the client side should be a json like this:
}
```

- The `service` key is used to select one of the microservices set on the application. You can read more about this here.
- The `model` key is used to select one of the models added to the application.
- The `act` key is used to select one of the acts added to the application.
- The `act` key is used to select one of the acts added to the application.
- The `service` key is used to select one of the `microservices` set on the application. You can read more about this here.
- The `model` key is used to select one of the `Models` added to the application.
- The `act` key is used to select one of the `Acts` added to the application.
- The `details` key is used to receive data to be sent from the client side along with data to be delivered to users. This key has two internal keys called `get` and `set`, we talked a little about it before.
- `set`: It contains the information we need in the main function. For this reason, we can extract `name`, `population`, and `abb` from within `body.details.set`.
- `set`: It contains the information we need in the `Act` function. For this reason, we can extract `name`, `population`, and `abb` from within `body.details.set`.
- `get`: Contains selected information that the user needs to be returned. Therefore, we can pass this object directly to Mongo `projection`.

As you can see, we have used the `insertOne` function, which was exported from the `countries` model, to add a new document. This function accepts an object as input, which has the following keys:
Expand Down
54 changes: 53 additions & 1 deletion pages/src/request_flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,58 @@ In order to access the `playground`, you must set the `playground` entry in the

### POST Requests:
We accept two models of `POST` requests:
- Requests sent to `upload` a document.
- Requests sent to `receive data` from the `server` (in fact, these requests are the main requests sent to **Lesan**).
- Requests sent to `upload` a document.

#### Receive data
To `receive data` from the **Lesan** server, you must send a `POST` request to the final address of **Lesan**.
In the `body` of this request, must be an `object` in `JSON` format with the following keys:

- The `service` key is used to select one of the `microservices` set on the application. This key is optional and by default the value of `main` is placed in it.
- The `model` key is used to select one of the `Models` added to the application.
- The `act` key is used to select one of the `Acts` added to the application.
- The `details` key is used to receive data to be sent from the client side along with data to be delivered to users. This key has two internal keys called `get` and `set`, we talked a little about it before.
- `set`: It contains the information we need in the `Act` function.
- `get`: Contains selected information that the user needs to be returned. This selection is based on `zero` or `one`. Therefore, we can pass this object directly to MongoDB `projection`.

An example of this `JSON` object is as follows:
```JSON
{
"service": "main",
"model": "country",
"act": "addCountry",
"details": {
"set": {
"name": "Iran",
"population": 85000000,
"abb": "IR"
},
"get": {
"_id": 1,
"name": 1,
"population": 1,
"cities": {
"name": 1,
"population": 1,
}
}
}
}
```

This request finally reaches the function we specified for `Act` to extract the necessary information from it and return the information requested by the user.
If you remember, we set up each `Act` as follows:
```ts
coreApp.acts.setAct({
schema: "user",
actName: "addUser",
validator: addUserValidator(),
fn: addUser,
preValidation: [setUser, checkLevel],
preAct: [justAdmin],
validationRunType: "create",
});
```

#### Upload documents
For uploading a document you should send a `POST` request to **Lesan** endpoint.
3 changes: 3 additions & 0 deletions src/models/mod.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { createProjection, TProjectionType } from "./createProjection.ts";
import { mainRelationsFns } from "./mainRelations/mod.ts";
import { pureFns } from "./pure/mod.ts";
import { relatedRelationFns } from "./relatedRelations/mod.ts";
Expand All @@ -18,6 +19,8 @@ export const schemas = (schemas: TSchemas) => {
...pureFns(schemas),
...relationFns(schemas),
...selectStructFns(schemas),
createProjection: (schemaName: string, projectionType: TProjectionType) =>
createProjection(schemas, schemaName, projectionType),
};
};

Expand Down

0 comments on commit cd79da1

Please sign in to comment.