https://deno.land/[email protected]/getting_started/installation
-
goto ./denojs/models
-
create some instances in the file
a_o_model.module.js
- cd
cd .denojs/models
- run
deno run -A create_strapi_models.module.js
- cd
cd .denojs/models
- run
deno run -A create_javascript_classes.module.js
foreach model there will be a class with all the properties and one with only the public properties for example
class
class O_person{
constructor(
s_name,
s_password // this is a private property
){
this.s_name = s_name
this.s_password = s_password // this is a private property
}
}
public class
class O_person{
constructor(
s_name,
){
this.s_name = s_name
}
}
there is only one relation which is a one-to-many
strapi has many-to-many relations but doesnt allow to have pivot columns on many-to-many tables so the solution is to have no many-to-many tables but have own models which have multiple one-to-many relations, this way custom pivot properties can be added
lets say a O_person has multiple 0_message , in the best case the tables would look like this
column | comment |
---|---|
n_id | the id number |
s_name | name of person |
column | |
---|---|
n_id | the id number |
n_o_person_n_id | the id number of o_person |
s_markdown | the content of the message |
so we just have to imagine on the existance of the o_person.n_id
property
//...
new O_model(
"O_person",
[
// note we do not have to create a `new O_model_property('n_id', 'number')` because strapi has built-in `id` properties
new O_model_property(
"s_name",
"string",
),
]
),
new O_model(
"O_message",
[
// note we do not have to create a `new O_model_property('n_id', 'number')` because strapi has built-in `id` properties
new O_model_property(
"n_o_person_n_id", // this is the 'one-to-many' relation of the O_person model , on e O_person can have many O_message
"number",
),
new O_model_property(
"s_markdown",
"string",
),
]
),
//...
the generated schema.json will look like this
O_person
{
"kind": "collectionType",
"collectionName": "o-person",
"info": {
"singularName": "o-person",
"pluralName": "a-o-person",
"displayName": "O_person",
"description": ""
},
"options": {
"populateCreatorFields": true
},
"pluginOptions": {},
"attributes": {
"s_name": {
"private": false,
"type": "string"
}
}
}
O_message
{
"kind": "collectionType",
"collectionName": "o-message",
"info": {
"singularName": "o-message",
"pluralName": "a-o-message",
"displayName": "O_message",
"description": ""
},
"options": {
"populateCreatorFields": true
},
"pluginOptions": {},
"attributes": {
"o_person": {
"private": false,
"type": "relation",
"relation": "oneToOne",
"target": "api::o-person.o-person"
},
"s_markdown": {
"private": false,
"type": "string"
}
}
}