Browse Source

chore: updates README.md

e22m4u 2 years ago
parent
commit
2e344e333c
82 changed files with 57 additions and 6 deletions
  1. 43 0
      README.md
  2. 9 2
      docs/assets/highlight.css
  3. 0 0
      docs/classes/Adapter.html
  4. 0 0
      docs/classes/AdapterLoader.html
  5. 0 0
      docs/classes/AdapterRegistry.html
  6. 0 0
      docs/classes/BelongsToResolver.html
  7. 0 0
      docs/classes/DatasourceDefinitionValidator.html
  8. 0 0
      docs/classes/DefinitionRegistry.html
  9. 0 0
      docs/classes/FieldsClauseTool.html
  10. 0 0
      docs/classes/HasManyResolver.html
  11. 0 0
      docs/classes/HasOneResolver.html
  12. 0 0
      docs/classes/IncludeClauseTool.html
  13. 0 0
      docs/classes/InvalidArgumentError.html
  14. 0 0
      docs/classes/InvalidOperatorValueError.html
  15. 0 0
      docs/classes/ModelDataSanitizer.html
  16. 0 0
      docs/classes/ModelDataValidator.html
  17. 0 0
      docs/classes/ModelDefinitionUtils.html
  18. 0 0
      docs/classes/ModelDefinitionValidator.html
  19. 0 0
      docs/classes/NotImplementedError.html
  20. 0 0
      docs/classes/OperatorClauseTool.html
  21. 0 0
      docs/classes/OrderClauseTool.html
  22. 0 0
      docs/classes/PrimaryKeysDefinitionValidator.html
  23. 0 0
      docs/classes/PropertiesDefinitionValidator.html
  24. 0 0
      docs/classes/ReferencesManyResolver.html
  25. 0 0
      docs/classes/RelationsDefinitionValidator.html
  26. 0 0
      docs/classes/Repository.html
  27. 0 0
      docs/classes/RepositoryRegistry.html
  28. 0 0
      docs/classes/Schema.html
  29. 0 0
      docs/classes/SliceClauseTool.html
  30. 0 0
      docs/classes/WhereClauseTool.html
  31. 0 0
      docs/enums/DataType.html
  32. 0 0
      docs/enums/RelationType.html
  33. 0 0
      docs/functions/capitalize.html
  34. 0 0
      docs/functions/cloneDeep.html
  35. 0 0
      docs/functions/excludeObjectKeys.html
  36. 0 0
      docs/functions/getCtorName.html
  37. 0 0
      docs/functions/getValueByPath.html
  38. 0 0
      docs/functions/isCtor.html
  39. 0 0
      docs/functions/isPureObject.html
  40. 0 0
      docs/functions/selectObjectKeys.html
  41. 0 0
      docs/functions/singularize.html
  42. 0 0
      docs/functions/stringToRegexp.html
  43. 1 0
      docs/index.html
  44. 0 0
      docs/interfaces/AndClause.html
  45. 0 0
      docs/interfaces/OrClause.html
  46. 0 0
      docs/types/AnyObject.html
  47. 0 0
      docs/types/BelongsToDefinition.html
  48. 0 0
      docs/types/DEFAULT_PRIMARY_KEY_PROPERTY_NAME.html
  49. 0 0
      docs/types/DatasourceDefinition.html
  50. 0 0
      docs/types/FieldsClause.html
  51. 0 0
      docs/types/FilterClause.html
  52. 0 0
      docs/types/Flatten.html
  53. 0 0
      docs/types/FullPropertyDefinition.html
  54. 0 0
      docs/types/HasManyDefinition.html
  55. 0 0
      docs/types/HasOneDefinition.html
  56. 0 0
      docs/types/Identity.html
  57. 4 4
      docs/types/IncludeClause.html
  58. 0 0
      docs/types/ItemFilterClause.html
  59. 0 0
      docs/types/ModelData.html
  60. 0 0
      docs/types/ModelDefinition.html
  61. 0 0
      docs/types/ModelId.html
  62. 0 0
      docs/types/NestedIncludeClause.html
  63. 0 0
      docs/types/NormalizedFieldsClause.html
  64. 0 0
      docs/types/NormalizedIncludeClause.html
  65. 0 0
      docs/types/OperatorClause.html
  66. 0 0
      docs/types/OptionalUnlessRequiredId.html
  67. 0 0
      docs/types/OrderClause.html
  68. 0 0
      docs/types/PartialBy.html
  69. 0 0
      docs/types/PartialWithoutId.html
  70. 0 0
      docs/types/PolyBelongsToDefinition.html
  71. 0 0
      docs/types/PolyHasManyDefinitionWithTargetKeys.html
  72. 0 0
      docs/types/PolyHasManyDefinitionWithTargetRelationName.html
  73. 0 0
      docs/types/PolyHasOneDefinitionWithTargetKeys.html
  74. 0 0
      docs/types/PolyHasOneDefinitionWithTargetRelationName.html
  75. 0 0
      docs/types/PropertiesClause.html
  76. 0 0
      docs/types/PropertyDefinition.html
  77. 0 0
      docs/types/PropertyDefinitionMap.html
  78. 0 0
      docs/types/ReferencesManyDefinition.html
  79. 0 0
      docs/types/RelationDefinition.html
  80. 0 0
      docs/types/RelationDefinitionMap.html
  81. 0 0
      docs/types/WhereClause.html
  82. 0 0
      docs/types/WithoutId.html

+ 43 - 0
README.md

@@ -13,6 +13,7 @@
 - [Репозиторий](#Репозиторий)
 - [Фильтрация](#Фильтрация)
 - [Связи](#Связи)
+- [Расширение](#Расширение)
 - [Тесты](#Тесты)
 - [Лицензия](#Лицензия)
 
@@ -570,6 +571,48 @@ schema.defineModel({
 })
 ```
 
+## Расширение
+
+Метод `getRepository` экземпляра схемы проверяет наличие существующего
+репозитория для указанной модели и возвращает его. В противном случае
+создается новый экземпляр, который будет сохранен для последующих
+обращений к методу.
+
+```js
+import {Schema} from '@e22m4u/js-repository';
+import {Repository} from '@e22m4u/js-repository';
+
+// const schema = new Schema();
+// schema.defineDatasource ...
+// schema.defineModel ...
+
+const rep1 = schema.getRepository('model');
+const rep2 = schema.getRepository('model');
+console.log(rep1 === rep2); // true
+```
+
+Подменить базовый конструктор репозитория можно методом `setRepositoryCtor`
+экземпляра схемы, после чего все создаваемые репозитории будут использовать
+указанный конструктор вместо стандартного.
+
+```js
+import {Schema} from '@e22m4u/js-repository';
+import {Repository} from '@e22m4u/js-repository';
+import {RepositoryRegistry} from '@e22m4u/js-repository';
+
+class MyRepository extends Repository {
+  /*...*/
+}
+
+const schema = new Schema();
+schema.get(RepositoryRegistry).setRepositoryCtor(MyRepository);
+// теперь schema.getRepository(modelName) будет возвращать
+// экземпляр класса MyRepository
+```
+
+Так как экземпляры репозитория кэшируется, то выполнять замену конструктора
+стоит именно до обращения к методу `getRepository` схемы.
+
 ## Тесты
 
 ```bash

+ 9 - 2
docs/assets/highlight.css

@@ -17,8 +17,10 @@
     --dark-hl-7: #4FC1FF;
     --light-hl-8: #098658;
     --dark-hl-8: #B5CEA8;
-    --light-hl-9: #000000;
-    --dark-hl-9: #C8C8C8;
+    --light-hl-9: #267F99;
+    --dark-hl-9: #4EC9B0;
+    --light-hl-10: #000000;
+    --dark-hl-10: #C8C8C8;
     --light-code-background: #FFFFFF;
     --dark-code-background: #1E1E1E;
 }
@@ -34,6 +36,7 @@
     --hl-7: var(--light-hl-7);
     --hl-8: var(--light-hl-8);
     --hl-9: var(--light-hl-9);
+    --hl-10: var(--light-hl-10);
     --code-background: var(--light-code-background);
 } }
 
@@ -48,6 +51,7 @@
     --hl-7: var(--dark-hl-7);
     --hl-8: var(--dark-hl-8);
     --hl-9: var(--dark-hl-9);
+    --hl-10: var(--dark-hl-10);
     --code-background: var(--dark-code-background);
 } }
 
@@ -62,6 +66,7 @@
     --hl-7: var(--light-hl-7);
     --hl-8: var(--light-hl-8);
     --hl-9: var(--light-hl-9);
+    --hl-10: var(--light-hl-10);
     --code-background: var(--light-code-background);
 }
 
@@ -76,6 +81,7 @@
     --hl-7: var(--dark-hl-7);
     --hl-8: var(--dark-hl-8);
     --hl-9: var(--dark-hl-9);
+    --hl-10: var(--dark-hl-10);
     --code-background: var(--dark-code-background);
 }
 
@@ -89,4 +95,5 @@
 .hl-7 { color: var(--hl-7); }
 .hl-8 { color: var(--hl-8); }
 .hl-9 { color: var(--hl-9); }
+.hl-10 { color: var(--hl-10); }
 pre, code { background: var(--code-background); }

File diff suppressed because it is too large
+ 0 - 0
docs/classes/Adapter.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/AdapterLoader.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/AdapterRegistry.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/BelongsToResolver.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/DatasourceDefinitionValidator.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/DefinitionRegistry.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/FieldsClauseTool.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/HasManyResolver.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/HasOneResolver.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/IncludeClauseTool.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/InvalidArgumentError.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/InvalidOperatorValueError.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/ModelDataSanitizer.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/ModelDataValidator.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/ModelDefinitionUtils.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/ModelDefinitionValidator.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/NotImplementedError.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/OperatorClauseTool.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/OrderClauseTool.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/PrimaryKeysDefinitionValidator.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/PropertiesDefinitionValidator.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/ReferencesManyResolver.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/RelationsDefinitionValidator.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/Repository.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/RepositoryRegistry.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/Schema.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/SliceClauseTool.html


File diff suppressed because it is too large
+ 0 - 0
docs/classes/WhereClauseTool.html


File diff suppressed because it is too large
+ 0 - 0
docs/enums/DataType.html


File diff suppressed because it is too large
+ 0 - 0
docs/enums/RelationType.html


File diff suppressed because it is too large
+ 0 - 0
docs/functions/capitalize.html


File diff suppressed because it is too large
+ 0 - 0
docs/functions/cloneDeep.html


File diff suppressed because it is too large
+ 0 - 0
docs/functions/excludeObjectKeys.html


File diff suppressed because it is too large
+ 0 - 0
docs/functions/getCtorName.html


File diff suppressed because it is too large
+ 0 - 0
docs/functions/getValueByPath.html


File diff suppressed because it is too large
+ 0 - 0
docs/functions/isCtor.html


File diff suppressed because it is too large
+ 0 - 0
docs/functions/isPureObject.html


File diff suppressed because it is too large
+ 0 - 0
docs/functions/selectObjectKeys.html


File diff suppressed because it is too large
+ 0 - 0
docs/functions/singularize.html


File diff suppressed because it is too large
+ 0 - 0
docs/functions/stringToRegexp.html


File diff suppressed because it is too large
+ 1 - 0
docs/index.html


File diff suppressed because it is too large
+ 0 - 0
docs/interfaces/AndClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/interfaces/OrClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/AnyObject.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/BelongsToDefinition.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/DEFAULT_PRIMARY_KEY_PROPERTY_NAME.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/DatasourceDefinition.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/FieldsClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/FilterClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/Flatten.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/FullPropertyDefinition.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/HasManyDefinition.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/HasOneDefinition.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/Identity.html


File diff suppressed because it is too large
+ 4 - 4
docs/types/IncludeClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/ItemFilterClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/ModelData.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/ModelDefinition.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/ModelId.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/NestedIncludeClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/NormalizedFieldsClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/NormalizedIncludeClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/OperatorClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/OptionalUnlessRequiredId.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/OrderClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/PartialBy.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/PartialWithoutId.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/PolyBelongsToDefinition.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/PolyHasManyDefinitionWithTargetKeys.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/PolyHasManyDefinitionWithTargetRelationName.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/PolyHasOneDefinitionWithTargetKeys.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/PolyHasOneDefinitionWithTargetRelationName.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/PropertiesClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/PropertyDefinition.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/PropertyDefinitionMap.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/ReferencesManyDefinition.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/RelationDefinition.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/RelationDefinitionMap.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/WhereClause.html


File diff suppressed because it is too large
+ 0 - 0
docs/types/WithoutId.html


Some files were not shown because too many files changed in this diff