Browse Source

chore: renames Schema to DatabaseSchema

e22m4u 5 months ago
parent
commit
67f3fe47a0

+ 79 - 80
README.md

@@ -2,24 +2,24 @@
 
 Реализация паттерна «Репозиторий» для работы с базами данных в Node.js
 
-- [Установка](#Установка)
-- [Импорт](#Импорт)
-- [Описание](#Описание)
-- [Пример](#Пример)
-- [Схема](#Схема)
-- [Источник данных](#Источник-данных)
-- [Модель](#Модель)
-- [Свойства](#Свойства)
-- [Валидаторы](#Валидаторы)
-- [Трансформеры](#Трансформеры)
-- [Пустые значения](#Пустые-значения)
-- [Репозиторий](#Репозиторий)
-- [Фильтрация](#Фильтрация)
-- [Связи](#Связи)
-- [Расширение](#Расширение)
-- [TypeScript](#TypeScript)
-- [Тесты](#Тесты)
-- [Лицензия](#Лицензия)
+- [Установка](#установка)
+- [Импорт](#импорт)
+- [Описание](#описание)
+- [Пример](#пример)
+- [Схема баз данных](#схема-баз-данных)
+- [Источник данных](#источник-данных)
+- [Модель](#модель)
+- [Свойства](#свойства)
+- [Валидаторы](#валидаторы)
+- [Трансформеры](#трансформеры)
+- [Пустые значения](#пустые-значения)
+- [Репозиторий](#репозиторий)
+- [Фильтрация](#фильтрация)
+- [Связи](#связи)
+- [Расширение](#расширение)
+- [TypeScript](#typescript)
+- [Тесты](#тесты)
+- [Лицензия](#лицензия)
 
 ## Установка
 
@@ -41,13 +41,13 @@ npm install @e22m4u/js-repository
 *ESM*
 
 ```js
-import {Schema} from '@e22m4u/js-repository';
+import {DatabaseSchema} from '@e22m4u/js-repository';
 ```
 
 *CommonJS*
 
 ```js
-const {Schema} = require('@e22m4u/js-repository');
+const {DatabaseSchema} = require('@e22m4u/js-repository');
 ```
 
 ## Описание
@@ -107,20 +107,20 @@ flowchart TD
 Объявление источника данных, модели и добавление нового документа в коллекцию.
 
 ```js
-import {Schema} from '@e22m4u/js-repository';
 import {DataType} from '@e22m4u/js-repository';
+import {DatabaseSchema} from '@e22m4u/js-repository';
 
-// создание экземпляра Schema
-const schema = new Schema();
+// создание экземпляра DatabaseSchema
+const dbs = new DatabaseSchema();
 
 // объявление источника "myMemory"
-schema.defineDatasource({
+dbs.defineDatasource({
   name: 'myMemory', // название нового источника
   adapter: 'memory', // выбранный адаптер
 });
 
 // объявление модели "country"
-schema.defineModel({
+dbs.defineModel({
   name: 'country', // название новой модели
   datasource: 'myMemory', // выбранный источник
   properties: { // свойства модели
@@ -130,7 +130,7 @@ schema.defineModel({
 })
 
 // получение репозитория модели "country"
-const countryRep = schema.getRepository('country');
+const countryRep = dbs.getRepository('country');
 
 // добавление нового документа в коллекцию "country"
 const country = await countryRep.create({
@@ -147,9 +147,9 @@ console.log(country);
 // }
 ```
 
-## Схема
+## Схема баз данных
 
-Экземпляр класса `Schema` хранит определения источников данных и моделей.
+Экземпляр класса `DatabaseSchema` хранит определения источников данных и моделей.
 
 **Методы**
 
@@ -162,15 +162,15 @@ console.log(country);
 Импорт класса и создание экземпляра схемы.
 
 ```js
-import {Schema} from '@e22m4u/js-repository';
+import {DatabaseSchema} from '@e22m4u/js-repository';
 
-const schema = new Schema();
+const dbs = new DatabaseSchema();
 ```
 
 Определение нового источника.
 
 ```js
-schema.defineDatasource({
+dbs.defineDatasource({
   name: 'myMemory', // название нового источника
   adapter: 'memory', // выбранный адаптер
 });
@@ -179,7 +179,7 @@ schema.defineDatasource({
 Определение новой модели.
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'product', // название новой модели
   datasource: 'myMemory', // выбранный источник
   properties: { // свойства модели
@@ -192,13 +192,14 @@ schema.defineModel({
 Получение репозитория по названию модели.
 
 ```js
-const productRep = schema.getRepository('product');
+const productRep = dbs.getRepository('product');
 ```
 
 ## Источник данных
 
 Источник хранит название выбранного адаптера и его настройки. Определение
-нового источника выполняется методом `defineDatasource` экземпляра схемы.
+нового источника выполняется методом `defineDatasource` экземпляра
+`DatabaseSchema`.
 
 **Параметры**
 
@@ -211,7 +212,7 @@ const productRep = schema.getRepository('product');
 Определение нового источника.
 
 ```js
-schema.defineDatasource({
+dbs.defineDatasource({
   name: 'myMemory', // название нового источника
   adapter: 'memory', // выбранный адаптер
 });
@@ -220,7 +221,7 @@ schema.defineDatasource({
 Передача дополнительных параметров адаптера.
 
 ```js
-schema.defineDatasource({
+dbs.defineDatasource({
   name: 'myMongodb',
   adapter: 'mongodb',
   // параметры адаптера "mongodb"
@@ -233,7 +234,7 @@ schema.defineDatasource({
 ## Модель
 
 Описывает структуру документа коллекции и связи к другим моделям. Определение
-новой модели выполняется методом `defineModel` экземпляра схемы.
+новой модели выполняется методом `defineModel` экземпляра `DatabaseSchema`.
 
 **Параметры**
 
@@ -249,7 +250,7 @@ schema.defineDatasource({
 Определение модели со свойствами указанного типа.
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'user', // название новой модели
   properties: { // свойства модели
     name: DataType.STRING,
@@ -314,7 +315,7 @@ schema.defineModel({
 Краткое определение свойств модели.
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'city',
   properties: { // свойства модели
     name: DataType.STRING, // тип свойства "string"
@@ -326,7 +327,7 @@ schema.defineModel({
 Расширенное определение свойств модели.
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'city',
   properties: { // свойства модели
     name: {
@@ -349,7 +350,7 @@ schema.defineModel({
 определено в момент записи документа.
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'article',
   properties: { // свойства модели
     tags: {
@@ -382,7 +383,7 @@ schema.defineModel({
 `validate`, который принимает объект с их названиями и настройками.
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'user',
   properties: {
     name: {
@@ -417,13 +418,11 @@ const numericValidator = (input) => {
 }
 
 // регистрация валидатора "numeric"
-schema
-  .get(PropertyValidatorRegistry)
-  .addValidator('numeric', numericValidator);
+dbs.get(PropertyValidatorRegistry).addValidator('numeric', numericValidator);
 
 // использование валидатора в определении
 // свойства "code" для новой модели
-schema.defineModel({
+dbs.defineModel({
   name: 'document',
   properties: {
     code: {
@@ -455,7 +454,7 @@ schema.defineModel({
 трансформера, а значением его параметры.
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'user',
   properties: {
     name: {
@@ -491,7 +490,7 @@ schema.defineModel({
 ## Репозиторий
 
 Выполняет операции чтения и записи документов определенной модели.
-Получить репозиторий можно методом `getRepository` экземпляра схемы.
+Получить репозиторий можно методом `getRepository` экземпляра `DatabaseSchema`.
 
 **Методы**
 
@@ -520,7 +519,7 @@ schema.defineModel({
 Получение репозитория по названию модели.
 
 ```js
-const countryRep = schema.getRepository('country');
+const countryRep = dbs.getRepository('country');
 ```
 
 Добавление нового документа в коллекцию.
@@ -745,7 +744,7 @@ const res = await rep.find({
 Объявление связи `belongsTo`
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'user',
   relations: {
     role: { // название связи
@@ -763,7 +762,7 @@ schema.defineModel({
 Объявление связи `hasMany`
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'role',
   relations: {
     users: { // название связи
@@ -778,7 +777,7 @@ schema.defineModel({
 Объявление связи `referencesMany`
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'article',
   relations: {
     categories: { // название связи
@@ -796,7 +795,7 @@ schema.defineModel({
 Полиморфная версия `belongsTo`
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'file',
   relations: {
     reference: { // название связи
@@ -815,7 +814,7 @@ schema.defineModel({
 Полиморфная версия `belongsTo` с указанием свойств.
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'file',
   relations: {
     reference: { // название связи
@@ -831,7 +830,7 @@ schema.defineModel({
 Полиморфная версия `hasMany` с указанием названия связи целевой модели.
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'letter',
   relations: {
     attachments: { // название связи
@@ -846,7 +845,7 @@ schema.defineModel({
 Полиморфная версия `hasMany` с указанием свойств целевой модели.
 
 ```js
-schema.defineModel({
+dbs.defineModel({
   name: 'letter',
   relations: {
     attachments: { // название связи
@@ -862,44 +861,44 @@ schema.defineModel({
 
 ## Расширение
 
-Метод `getRepository` экземпляра схемы проверяет наличие существующего
-репозитория для указанной модели и возвращает его. В противном случае
-создается новый экземпляр, который будет сохранен для последующих
-обращений к методу.
+Метод `getRepository` экземпляра `DatabaseSchema` проверяет наличие
+существующего  репозитория для указанной модели и возвращает его.
+В противном случае создается новый экземпляр, который будет сохранен
+для последующих обращений к методу.
 
 ```js
-import {Schema} from '@e22m4u/js-repository';
 import {Repository} from '@e22m4u/js-repository';
+import {DatabaseSchema} from '@e22m4u/js-repository';
 
-// const schema = new Schema();
-// schema.defineDatasource ...
-// schema.defineModel ...
+// const dbs = new DatabaseSchema();
+// dbs.defineDatasource ...
+// dbs.defineModel ...
 
-const rep1 = schema.getRepository('model');
-const rep2 = schema.getRepository('model');
+const rep1 = dbs.getRepository('model');
+const rep2 = dbs.getRepository('model');
 console.log(rep1 === rep2); // true
 ```
 
 Подмена стандартного конструктора репозитория выполняется методом
 `setRepositoryCtor` сервиса `RepositoryRegistry`, который находится
контейнере экземпляра схемы. После чего все новые репозитории будут
-создаваться указанным конструктором вместо стандартного.
сервис-контейнере экземпляра `DatabaseSchema`. После чего все новые
+репозитории будут создаваться указанным конструктором вместо стандартного.
 
 ```js
-import {Schema} from '@e22m4u/js-repository';
 import {Repository} from '@e22m4u/js-repository';
+import {DatabaseSchema} from '@e22m4u/js-repository';
 import {RepositoryRegistry} from '@e22m4u/js-repository';
 
 class MyRepository extends Repository {
   /*...*/
 }
 
-// const schema = new Schema();
-// schema.defineDatasource ...
-// schema.defineModel ...
+// const dbs = new DatabaseSchema();
+// dbs.defineDatasource ...
+// dbs.defineModel ...
 
-schema.get(RepositoryRegistry).setRepositoryCtor(MyRepository);
-const rep = schema.getRepository('model');
+dbs.get(RepositoryRegistry).setRepositoryCtor(MyRepository);
+const rep = dbs.getRepository('model');
 console.log(rep instanceof MyRepository); // true
 ```
 
@@ -911,16 +910,16 @@ console.log(rep instanceof MyRepository); // true
 Получение типизированного репозитория с указанием интерфейса модели.
 
 ```ts
-import {Schema} from '@e22m4u/js-repository';
 import {DataType} from '@e22m4u/js-repository';
 import {RelationType} from '@e22m4u/js-repository';
+import {DatabaseSchema} from '@e22m4u/js-repository';
 
-// const schema = new Schema();
-// schema.defineDatasource ...
-// schema.defineModel ...
+// const dbs = new DatabaseSchema();
+// dbs.defineDatasource ...
+// dbs.defineModel ...
 
 // определение модели "city"
-schema.defineModel({
+dbs.defineModel({
   name: 'city',
   datasource: 'myDatasource',
   properties: {
@@ -946,7 +945,7 @@ interface City {
 
 // получаем репозиторий по названию модели
 // указывая ее тип и тип идентификатора
-const cityRep = schema.getRepository<City, number>('city');
+const cityRep = dbs.getRepository<City, number>('city');
 ```
 
 ## Тесты

File diff suppressed because it is too large
+ 2462 - 2462
dist/cjs/index.cjs


+ 4 - 4
package.json

@@ -60,14 +60,14 @@
     "eslint": "~9.28.0",
     "eslint-config-prettier": "~10.1.5",
     "eslint-plugin-chai-expect": "~3.1.0",
-    "eslint-plugin-jsdoc": "~50.7.0",
+    "eslint-plugin-jsdoc": "~50.8.0",
     "eslint-plugin-mocha": "~11.1.0",
     "husky": "~9.1.7",
-    "mocha": "~11.5.0",
+    "mocha": "~11.6.0",
     "prettier": "~3.5.3",
     "rimraf": "~6.0.1",
-    "tsx": "~4.19.4",
+    "tsx": "~4.20.2",
     "typescript": "~5.8.3",
-    "typescript-eslint": "~8.33.0"
+    "typescript-eslint": "~8.34.0"
   }
 }

+ 3 - 3
src/adapter/adapter-registry.spec.js

@@ -1,12 +1,12 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
+import {DatabaseSchema} from '../database-schema.js';
 import {AdapterRegistry} from './adapter-registry.js';
 import {MemoryAdapter} from './builtin/memory-adapter.js';
 
 describe('AdapterRegistry', function () {
   describe('getAdapter', function () {
     it('instantiates a new or returns an existing adapter by a given datasource name', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       const R = S.getService(AdapterRegistry);
       const adapter = await R.getAdapter('datasource');
@@ -24,7 +24,7 @@ describe('AdapterRegistry', function () {
     });
 
     it('throws an error if an adapter is not exists', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'unknown'});
       const R = S.getService(AdapterRegistry);
       const promise = R.getAdapter('datasource');

+ 2 - 2
src/adapter/adapter.spec.js

@@ -1,10 +1,10 @@
 import {expect} from 'chai';
 import {chai} from '../chai.js';
-import {Schema} from '../schema.js';
 import {Adapter} from './adapter.js';
 import {Service} from '@e22m4u/js-service';
 import {ADAPTER_CLASS_NAME} from './adapter.js';
 import {ServiceContainer} from '@e22m4u/js-service';
+import {DatabaseSchema} from '../database-schema.js';
 import {InclusionDecorator} from './decorator/index.js';
 import {DefaultValuesDecorator} from './decorator/index.js';
 import {DataValidationDecorator} from './decorator/index.js';
@@ -42,7 +42,7 @@ describe('Adapter', function () {
     });
 
     it('decorates only extended adapter', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       const dec1 = schema.getService(DataSanitizingDecorator);
       const dec2 = schema.getService(DefaultValuesDecorator);
       const dec3 = schema.getService(DataTransformationDecorator);

File diff suppressed because it is too large
+ 112 - 112
src/adapter/builtin/memory-adapter.spec.js


+ 2 - 2
src/adapter/decorator/data-sanitizing-decorator.spec.js

@@ -1,10 +1,10 @@
 import {expect} from 'chai';
 import {chai} from '../../chai.js';
 import {Adapter} from '../adapter.js';
-import {Schema} from '../../schema.js';
+import {DatabaseSchema} from '../../database-schema.js';
 import {ModelDataSanitizer} from '../../definition/index.js';
 
-const S = new Schema();
+const S = new DatabaseSchema();
 S.defineModel({name: 'model'});
 
 class TestAdapter extends Adapter {

+ 2 - 2
src/adapter/decorator/data-transformation-decorator.spec.js

@@ -1,7 +1,7 @@
 import {expect} from 'chai';
 import {chai} from '../../chai.js';
 import {Adapter} from '../adapter.js';
-import {Schema} from '../../schema.js';
+import {DatabaseSchema} from '../../database-schema.js';
 import {ModelDataTransformer} from '../../definition/index.js';
 
 const MODEL_NAME = 'myModel';
@@ -46,7 +46,7 @@ class TestAdapter extends Adapter {
   }
 }
 
-const S = new Schema();
+const S = new DatabaseSchema();
 S.defineModel({name: MODEL_NAME});
 const A = S.getService(TestAdapter);
 const T = S.getService(ModelDataTransformer);

+ 2 - 2
src/adapter/decorator/data-validation-decorator.spec.js

@@ -1,10 +1,10 @@
 import {expect} from 'chai';
 import {chai} from '../../chai.js';
 import {Adapter} from '../adapter.js';
-import {Schema} from '../../schema.js';
+import {DatabaseSchema} from '../../database-schema.js';
 import {ModelDataValidator} from '../../definition/index.js';
 
-const S = new Schema();
+const S = new DatabaseSchema();
 S.defineModel({name: 'model'});
 
 class TestAdapter extends Adapter {

+ 2 - 2
src/adapter/decorator/default-values-decorator.spec.js

@@ -1,11 +1,11 @@
 import {expect} from 'chai';
 import {chai} from '../../chai.js';
 import {Adapter} from '../adapter.js';
-import {Schema} from '../../schema.js';
 import {DataType} from '../../definition/index.js';
+import {DatabaseSchema} from '../../database-schema.js';
 import {ModelDefinitionUtils} from '../../definition/index.js';
 
-const S = new Schema();
+const S = new DatabaseSchema();
 S.defineModel({
   name: 'model',
   properties: {

+ 2 - 2
src/adapter/decorator/fields-filtering-decorator.spec.js

@@ -1,10 +1,10 @@
 import {expect} from 'chai';
 import {chai} from '../../chai.js';
 import {Adapter} from '../adapter.js';
-import {Schema} from '../../schema.js';
 import {FieldsClauseTool} from '../../filter/index.js';
+import {DatabaseSchema} from '../../database-schema.js';
 
-const S = new Schema();
+const S = new DatabaseSchema();
 const MODEL_NAME = 'model';
 S.defineModel({name: MODEL_NAME});
 

+ 2 - 2
src/adapter/decorator/inclusion-decorator.spec.js

@@ -1,10 +1,10 @@
 import {expect} from 'chai';
 import {chai} from '../../chai.js';
 import {Adapter} from '../adapter.js';
-import {Schema} from '../../schema.js';
+import {DatabaseSchema} from '../../database-schema.js';
 import {IncludeClauseTool} from '../../filter/index.js';
 
-const S = new Schema();
+const S = new DatabaseSchema();
 S.defineModel({name: 'model'});
 const FILTER = {include: 'parent'};
 

+ 2 - 2
src/adapter/decorator/property-uniqueness-decorator.spec.js

@@ -1,10 +1,10 @@
 import {expect} from 'chai';
 import {chai} from '../../chai.js';
 import {Adapter} from '../adapter.js';
-import {Schema} from '../../schema.js';
+import {DatabaseSchema} from '../../database-schema.js';
 import {PropertyUniquenessValidator} from '../../definition/index.js';
 
-const S = new Schema();
+const S = new DatabaseSchema();
 S.defineModel({name: 'model'});
 
 class TestAdapter extends Adapter {

+ 2 - 2
src/schema.d.ts → src/database-schema.d.ts

@@ -7,9 +7,9 @@ import {DatasourceDefinition} from './definition/index.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME} from './definition/index.js';
 
 /**
- * Schema.
+ * Database schema.
  */
-export declare class Schema extends Service {
+export declare class DatabaseSchema extends Service {
   /**
    * Define datasource.
    *

+ 2 - 2
src/schema.js → src/database-schema.js

@@ -4,9 +4,9 @@ import {DefinitionRegistry} from './definition/index.js';
 import {RepositoryRegistry} from './repository/index.js';
 
 /**
- * Schema.
+ * Database schema.
  */
-export class Schema extends Service {
+export class DatabaseSchema extends Service {
   /**
    * Define datasource.
    *

+ 30 - 30
src/schema.spec.ts → src/database-schema.spec.ts

@@ -1,32 +1,32 @@
 import {expect} from 'chai';
-import {Schema} from './schema.js';
 import {Repository} from './repository/index.js';
+import {DatabaseSchema} from './database-schema.js';
 import {DefinitionRegistry} from './definition/index.js';
 
 describe('Schema', function () {
   describe('defineDatasource', function () {
     it('returns this', function () {
-      const schema = new Schema();
-      const res = schema.defineDatasource({
+      const dbs = new DatabaseSchema();
+      const res = dbs.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
       });
-      expect(res).to.be.eq(schema);
+      expect(res).to.be.eq(dbs);
     });
 
     it('sets the datasource definition', function () {
-      const schema = new Schema();
-      schema.defineDatasource({name: 'datasource', adapter: 'memory'});
+      const dbs = new DatabaseSchema();
+      dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
       const res =
-        schema.getService(DefinitionRegistry).getDatasource('datasource');
+        dbs.getService(DefinitionRegistry).getDatasource('datasource');
       expect(res).to.be.eql({name: 'datasource', adapter: 'memory'});
     });
 
     it('throws an error if the datasource name already defined', function () {
-      const schema = new Schema();
-      schema.defineDatasource({name: 'datasource', adapter: 'memory'});
+      const dbs = new DatabaseSchema();
+      dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
       const throwable =
-        () => schema.defineDatasource({name: 'datasource', adapter: 'memory'});
+        () => dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
       expect(throwable).to.throw(
         'The datasource "datasource" is already defined.',
       );
@@ -35,51 +35,51 @@ describe('Schema', function () {
 
   describe('defineModel', function () {
     it('returns this', function () {
-      const schema = new Schema();
-      const res = schema.defineModel({name: 'model'});
-      expect(res).to.be.eq(schema);
+      const dbs = new DatabaseSchema();
+      const res = dbs.defineModel({name: 'model'});
+      expect(res).to.be.eq(dbs);
     });
 
     it('sets the model definition', function () {
-      const schema = new Schema();
-      schema.defineModel({name: 'model'});
-      const res = schema.getService(DefinitionRegistry).getModel('model');
+      const dbs = new DatabaseSchema();
+      dbs.defineModel({name: 'model'});
+      const res = dbs.getService(DefinitionRegistry).getModel('model');
       expect(res).to.be.eql({name: 'model'});
     });
 
     it('throws an error if the model name already defined', function () {
-      const schema = new Schema();
-      schema.defineModel({name: 'model'});
-      const throwable = () => schema.defineModel({name: 'model'});
+      const dbs = new DatabaseSchema();
+      dbs.defineModel({name: 'model'});
+      const throwable = () => dbs.defineModel({name: 'model'});
       expect(throwable).to.throw('The model "model" is already defined.');
     });
   });
 
   describe('getRepository', function () {
     it('returns a repository by the model name', function () {
-      const schema = new Schema();
-      schema.defineDatasource({name: 'datasource', adapter: 'memory'});
-      schema.defineModel({name: 'model', datasource: 'datasource'});
-      const res = schema.getRepository('model');
+      const dbs = new DatabaseSchema();
+      dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
+      dbs.defineModel({name: 'model', datasource: 'datasource'});
+      const res = dbs.getRepository('model');
       expect(res).to.be.instanceof(Repository);
     });
 
     it('throws an error if the model is not defined', function () {
-      const schema = new Schema();
-      const throwable = () => schema.getRepository('model');
+      const dbs = new DatabaseSchema();
+      const throwable = () => dbs.getRepository('model');
       expect(throwable).to.throw('The model "model" is not defined.');
     });
 
     it('uses generic types to define the repository type', function () {
-      const schema = new Schema();
-      schema.defineDatasource({name: 'datasource', adapter: 'memory'});
-      schema.defineModel({name: 'model', datasource: 'datasource'});
+      const dbs = new DatabaseSchema();
+      dbs.defineDatasource({name: 'datasource', adapter: 'memory'});
+      dbs.defineModel({name: 'model', datasource: 'datasource'});
       interface MyModel {
         myId: number;
       }
-      const res1: Repository = schema.getRepository('model');
+      const res1: Repository = dbs.getRepository('model');
       const res2: Repository<MyModel, number, 'myId'> =
-        schema.getRepository<MyModel, number, 'myId'>('model');
+        dbs.getRepository<MyModel, number, 'myId'>('model');
       expect(res1).to.be.eq(res2);
     });
   });

+ 25 - 25
src/definition/model/model-data-transformer.spec.js

@@ -1,7 +1,7 @@
 import {expect} from 'chai';
-import {Schema} from '../../schema.js';
 import {format} from '@e22m4u/js-format';
 import {DataType} from './properties/index.js';
+import {DatabaseSchema} from '../../database-schema.js';
 import {DefinitionRegistry} from '../definition-registry.js';
 import {ModelDataTransformer} from './model-data-transformer.js';
 import {PropertyTransformerRegistry} from './properties/index.js';
@@ -9,14 +9,14 @@ import {PropertyTransformerRegistry} from './properties/index.js';
 describe('ModelDataTransformer', function () {
   describe('transform', function () {
     it('throws an error if the given model name is not defined', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       const T = schema.getService(ModelDataTransformer);
       const throwable = () => T.transform('model', {});
       expect(throwable).to.throw('The model "model" is not defined.');
     });
 
     it('throws an error if the given model data is not a pure object', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       const T = schema.getService(ModelDataTransformer);
       const throwable = v => () => T.transform('model', v);
       const error = v =>
@@ -37,7 +37,7 @@ describe('ModelDataTransformer', function () {
     });
 
     it('does nothing with the given model if no transformers are set', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -56,7 +56,7 @@ describe('ModelDataTransformer', function () {
 
     describe('the option "transform" with a string value', function () {
       it('transforms the property value by its transformer', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = value => String(value);
         schema
           .getService(PropertyTransformerRegistry)
@@ -76,7 +76,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('passes specific arguments to the transformer function', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = (value, options, context) => {
           expect(value).to.be.eq('input');
           expect(options).to.be.undefined;
@@ -105,7 +105,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('does not transform a property value if it is not provided', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = () => 'transformed';
         schema
           .getService(PropertyTransformerRegistry)
@@ -125,7 +125,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('does not transform undefined and null values', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = () => 'transformed';
         schema
           .getService(PropertyTransformerRegistry)
@@ -147,7 +147,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('the parameter "isPartial" prevents to transform values of not provided properties', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = () => 'transformed';
         schema
           .getService(PropertyTransformerRegistry)
@@ -167,7 +167,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('transforms the property value by its asynchronous transformer', async function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer1 = (value, options) => {
           expect(options).to.be.undefined;
           return Promise.resolve(`${value}2`);
@@ -203,7 +203,7 @@ describe('ModelDataTransformer', function () {
 
     describe('the option "transform" with an array value', function () {
       it('transforms given properties by their transformers', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = value => String(value);
         schema
           .getService(PropertyTransformerRegistry)
@@ -231,7 +231,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('transforms the property value by its transformers in specified order', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const order = [];
         const myTransformer1 = value => {
           order.push('myTransformer1');
@@ -261,7 +261,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('passes specific arguments to the transformer function', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = (value, options, context) => {
           expect(value).to.be.eq('input');
           expect(options).to.be.undefined;
@@ -290,7 +290,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('does not transform a property value if it is not provided', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = () => 'transformed';
         schema
           .getService(PropertyTransformerRegistry)
@@ -310,7 +310,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('transforms undefined and null values', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = () => 'transformed';
         schema
           .getService(PropertyTransformerRegistry)
@@ -332,7 +332,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('the parameter "isPartial" prevents to transform values of not provided properties', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = () => 'transformed';
         schema
           .getService(PropertyTransformerRegistry)
@@ -352,7 +352,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('transforms the property value by its asynchronous transformers', async function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer1 = (value, options) => {
           expect(options).to.be.undefined;
           return Promise.resolve(`${value}2`);
@@ -393,7 +393,7 @@ describe('ModelDataTransformer', function () {
 
     describe('the option "transform" with an object value', function () {
       it('transforms given properties by their transformers', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = value => String(value);
         schema
           .getService(PropertyTransformerRegistry)
@@ -421,7 +421,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('transforms the property value by its transformers in specified order', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const order = [];
         const myTransformer1 = value => {
           order.push('myTransformer1');
@@ -454,7 +454,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('passes specific arguments to the transformer function', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = (value, options, context) => {
           expect(value).to.be.eq('input');
           expect(options).to.be.eql({
@@ -491,7 +491,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('does not transform a property value if it is not provided', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = () => 'transformed';
         schema
           .getService(PropertyTransformerRegistry)
@@ -513,7 +513,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('transforms undefined and null values', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = () => 'transformed';
         schema
           .getService(PropertyTransformerRegistry)
@@ -537,7 +537,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('the parameter "isPartial" prevents to transform values of not provided properties', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer = () => 'transformed';
         schema
           .getService(PropertyTransformerRegistry)
@@ -559,7 +559,7 @@ describe('ModelDataTransformer', function () {
       });
 
       it('transforms the property value by its asynchronous transformers', async function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         const myTransformer1 = (value, options) => {
           expect(options).to.be.eq('foo');
           return Promise.resolve(`${value}2`);
@@ -605,7 +605,7 @@ describe('ModelDataTransformer', function () {
     });
 
     it('the option "transform" requires a non-empty String, an Array or an Object', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema
         .getService(PropertyTransformerRegistry)
         .addTransformer('myTransformer', () => 'transformed');

File diff suppressed because it is too large
+ 112 - 112
src/definition/model/model-data-validator.spec.js


+ 100 - 100
src/definition/model/model-definition-utils.spec.js

@@ -1,9 +1,9 @@
 import {expect} from 'chai';
 import {chai} from '../../chai.js';
-import {Schema} from '../../schema.js';
 import {format} from '@e22m4u/js-format';
 import {DataType} from './properties/index.js';
 import {RelationType} from './relations/index.js';
+import {DatabaseSchema} from '../../database-schema.js';
 import {EmptyValuesService} from '@e22m4u/js-empty-values';
 import {InvalidArgumentError} from '../../errors/index.js';
 import {ModelDefinitionUtils} from './model-definition-utils.js';
@@ -18,7 +18,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getPrimaryKeyAsPropertyName', function () {
     it('returns a default property name if no primary key defined', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -29,7 +29,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error if a property name of a default primary key already in use as a regular property', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       const S = schema.getService(ModelDefinitionUtils);
       sandbox.on(
         S,
@@ -51,7 +51,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a property name if a primary key has a custom name and a default primary key is used as a regular property', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -69,7 +69,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a property name of a primary key', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -89,7 +89,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to get a property name of a primary key', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -112,7 +112,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getPrimaryKeyAsColumnName', function () {
     it('returns a property name of a primary key if a column name is not specified', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -132,7 +132,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a column name of a primary key if specified', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -153,7 +153,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a default property name if a primary key is not defined', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -164,7 +164,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error if a property name of a default primary key already in use as a regular property', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       const S = schema.getService(ModelDefinitionUtils);
       sandbox.on(
         S,
@@ -186,7 +186,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a property name of a custom primary key when a default primary key is used as a regular property', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -204,7 +204,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to get a column name of a primary key', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -227,7 +227,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getTableNameByModelName', function () {
     it('returns a model name if no table name specified', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -238,7 +238,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a table name from a model definition', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         tableName: 'table',
@@ -252,7 +252,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getColumnNameByPropertyName', function () {
     it('returns a property name if a column name is not defined', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -266,7 +266,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a specified column name', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -283,7 +283,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error if a given property name does not exist', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -295,7 +295,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to get a specified column name', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -318,7 +318,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getDefaultPropertyValue', function () {
     it('returns undefined if no default value specified', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -332,7 +332,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a default value from a property definition', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -349,7 +349,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a value from a factory function', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -366,7 +366,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error if a given property name does not exist', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -378,7 +378,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to get a specified default value', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -401,7 +401,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('setDefaultValuesToEmptyProperties', function () {
     it('does nothing if no property definitions', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -412,7 +412,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('does nothing if no "default" option in property definition', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -427,7 +427,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('sets a default value if a property does not exist', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -444,7 +444,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('sets a default value if a property is undefined', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -461,7 +461,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('sets a default value if a property is null', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -478,7 +478,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('sets a default value if a property has an empty value', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -498,7 +498,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('sets a value from a factory function', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -532,7 +532,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to set a default values', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -566,7 +566,7 @@ describe('ModelDefinitionUtils', function () {
 
     describe('an option "onlyProvidedProperties" is true', function () {
       it('does not set a default value if a property does not exist', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -583,7 +583,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('sets a default value if a property is undefined', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -600,7 +600,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('sets a default value if a property is null', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -620,7 +620,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('convertPropertyNamesToColumnNames', function () {
     it('does nothing if no property definitions', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -631,7 +631,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('does nothing if no column name specified', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -646,7 +646,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('replaces property names by column names', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -667,7 +667,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to replace property names by column names', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -693,7 +693,7 @@ describe('ModelDefinitionUtils', function () {
 
     describe('embedded object with model', function () {
       it('does nothing if no property definitions', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'modelA',
           properties: {
@@ -715,7 +715,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('does nothing if no column name specified', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'modelA',
           properties: {
@@ -741,7 +741,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('replaces property names by column names', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'modelA',
           properties: {
@@ -777,7 +777,7 @@ describe('ModelDefinitionUtils', function () {
 
     describe('embedded array with items model', function () {
       it('does nothing if no property definitions', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'modelA',
           properties: {
@@ -800,7 +800,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('does nothing if no column name specified', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'modelA',
           properties: {
@@ -835,7 +835,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('replaces property names by column names', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'modelA',
           properties: {
@@ -879,7 +879,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('convertColumnNamesToPropertyNames', function () {
     it('does nothing if no property definitions', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -890,7 +890,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('does nothing if no column name specified', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -905,7 +905,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('replaces column names by property names', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -926,7 +926,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to replace column names by property names', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -952,7 +952,7 @@ describe('ModelDefinitionUtils', function () {
 
     describe('embedded object with model', function () {
       it('does nothing if no property definitions', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'modelA',
           properties: {
@@ -974,7 +974,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('does nothing if no column name specified', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'modelA',
           properties: {
@@ -1000,7 +1000,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('replaces property names by column names', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'modelA',
           properties: {
@@ -1034,7 +1034,7 @@ describe('ModelDefinitionUtils', function () {
 
     describe('embedded array with items model', function () {
       it('does nothing if no property definitions', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'modelA',
           properties: {
@@ -1057,7 +1057,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('does nothing if no column name specified', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'modelA',
           properties: {
@@ -1092,7 +1092,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('replaces property names by column names', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'modelA',
           properties: {
@@ -1136,7 +1136,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getDataTypeByPropertyName', function () {
     it('returns a property type of a short property definition', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -1150,7 +1150,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a property type of a full property definition', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -1166,7 +1166,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error if a property name does not exist', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -1178,7 +1178,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to get a type from a short property definition', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -1196,7 +1196,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a base model hierarchy to get a type from a full property definition', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -1218,7 +1218,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getDataTypeFromPropertyDefinition', function () {
     it('requires the given argument "propDef" must be an Object or DataType', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       const S = schema.getService(ModelDefinitionUtils);
       const throwable = v => () => S.getDataTypeFromPropertyDefinition(v);
       const error = v =>
@@ -1240,7 +1240,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('requires the given Object to have the "type" property with the DataType enum', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       const S = schema.getService(ModelDefinitionUtils);
       const throwable = v => () =>
         S.getDataTypeFromPropertyDefinition({type: v});
@@ -1263,14 +1263,14 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns the DataType from the given DataType enum', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       const S = schema.getService(ModelDefinitionUtils);
       const res = S.getDataTypeFromPropertyDefinition(DataType.STRING);
       expect(res).to.be.eq(DataType.STRING);
     });
 
     it('returns the DataType from the given PropertyDefinition', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       const S = schema.getService(ModelDefinitionUtils);
       const res = S.getDataTypeFromPropertyDefinition({type: DataType.STRING});
       expect(res).to.be.eq(DataType.STRING);
@@ -1279,7 +1279,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getOwnPropertiesDefinitionWithoutPrimaryKeys', function () {
     it('returns an empty object if a model does not have properties', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -1290,7 +1290,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a properties definition without primary keys', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -1312,7 +1312,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns its own properties definition even it has a base model properties', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -1346,7 +1346,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getOwnPropertiesDefinitionOfPrimaryKeys', function () {
     it('returns an empty object if a model does not have properties', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -1357,7 +1357,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a properties definition of primary keys', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -1381,7 +1381,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns its own properties definition even it has a base model properties', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -1418,7 +1418,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getPropertiesDefinitionInBaseModelHierarchy', function () {
     it('returns an empty object if a model does not have properties', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -1429,7 +1429,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a properties definition of a model', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -1455,7 +1455,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a properties definition of an extended model', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -1479,7 +1479,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses child properties in priority over a base model properties', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -1516,7 +1516,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses primary keys from a model closest to child model', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         properties: {
@@ -1552,7 +1552,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error for a circular reference', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         base: 'model',
@@ -1569,7 +1569,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getOwnRelationsDefinition', function () {
     it('returns an empty object if a model does not have relations', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -1580,7 +1580,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a relations definition by a given model', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         relations: {
@@ -1602,7 +1602,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns its own relations definition even it has a base model relations', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         relations: {
@@ -1636,7 +1636,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getRelationsDefinitionInBaseModelHierarchy', function () {
     it('returns an empty object if a model does not have relations', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -1647,7 +1647,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a relations definition of a model', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         relations: {
@@ -1677,7 +1677,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a relations definition of an extended model', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         relations: {
@@ -1713,7 +1713,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses child relations in priority over a base model relations', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         relations: {
@@ -1753,7 +1753,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error for a circular reference', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         base: 'model',
@@ -1770,7 +1770,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getRelationDefinitionByName', function () {
     it('throws an error if a given model is not found', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       const throwable = () =>
         schema
           .getService(ModelDefinitionUtils)
@@ -1779,7 +1779,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('throws an error if a given relation is not found', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
       });
@@ -1793,7 +1793,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a relation definition by a given name', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         relations: {
@@ -1813,7 +1813,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('uses a child relations in priority over a base model relations', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         relations: {
@@ -1843,7 +1843,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('returns a base model relation if a given relation name is not found in a child model', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'modelA',
         relations: {
@@ -1869,7 +1869,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('excludeObjectKeysByRelationNames', function () {
     it('excludes object keys by relation names', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         relations: {
@@ -1897,7 +1897,7 @@ describe('ModelDefinitionUtils', function () {
     });
 
     it('requires a given object as an object', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({name: 'model'});
       const throwable = v => () =>
         schema
@@ -1924,7 +1924,7 @@ describe('ModelDefinitionUtils', function () {
 
   describe('getModelNameOfPropertyValueIfDefined', function () {
     it('returns undefined if a given property does not exist in the model', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({name: 'model'});
       const S = schema.getService(ModelDefinitionUtils);
       const res = S.getModelNameOfPropertyValueIfDefined('model', 'foo');
@@ -1933,7 +1933,7 @@ describe('ModelDefinitionUtils', function () {
 
     describe('short property definition', function () {
       it('requires parameter "modelName" to be a non-empty String', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -1962,7 +1962,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('requires parameter "propertyName" to be a non-empty String', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -1992,7 +1992,7 @@ describe('ModelDefinitionUtils', function () {
 
       it('returns undefined if the property definition is DataType', function () {
         const fn = v => {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2013,7 +2013,7 @@ describe('ModelDefinitionUtils', function () {
 
     describe('full property definition', function () {
       it('requires parameter "modelName" to be a non-empty String', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -2044,7 +2044,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('requires parameter "propertyName" to be a non-empty String', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -2076,7 +2076,7 @@ describe('ModelDefinitionUtils', function () {
 
       it('return undefined if no model name specified', function () {
         const fn = v => {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2098,7 +2098,7 @@ describe('ModelDefinitionUtils', function () {
 
       it('return undefined if no model name specified in case of Array property', function () {
         const fn = v => {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2120,7 +2120,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('returns a model name from the option "model" in case of Object property', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'model',
           properties: {
@@ -2136,7 +2136,7 @@ describe('ModelDefinitionUtils', function () {
       });
 
       it('returns a model name from the option "itemModel" in case of Array property', function () {
-        const schema = new Schema();
+        const schema = new DatabaseSchema();
         schema.defineModel({
           name: 'model',
           properties: {

+ 92 - 92
src/definition/model/properties/property-uniqueness-validator.spec.js

@@ -1,7 +1,7 @@
 import {expect} from 'chai';
 import {DataType} from './data-type.js';
 import {format} from '@e22m4u/js-format';
-import {Schema} from '../../../schema.js';
+import {DatabaseSchema} from '../../../database-schema.js';
 import {EmptyValuesService} from '@e22m4u/js-empty-values';
 import {PropertyUniqueness} from './property-uniqueness.js';
 import {PropertyUniquenessValidator} from './property-uniqueness-validator.js';
@@ -10,7 +10,7 @@ import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../model-definition-u
 describe('PropertyUniquenessValidator', function () {
   describe('validate', function () {
     it('requires the parameter "countMethod" to be a Function', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -45,7 +45,7 @@ describe('PropertyUniquenessValidator', function () {
     });
 
     it('requires the parameter "methodName" to be a non-empty String', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -80,7 +80,7 @@ describe('PropertyUniquenessValidator', function () {
     });
 
     it('requires the parameter "modelName" to be a non-empty String', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -115,7 +115,7 @@ describe('PropertyUniquenessValidator', function () {
     });
 
     it('requires the parameter "modelData" to be a pure Object', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -149,7 +149,7 @@ describe('PropertyUniquenessValidator', function () {
     });
 
     it('skips checking if the option "unique" is not provided', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -165,7 +165,7 @@ describe('PropertyUniquenessValidator', function () {
     });
 
     it('skips checking if the option "unique" is undefined', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -181,7 +181,7 @@ describe('PropertyUniquenessValidator', function () {
     });
 
     it('skips checking if the option "unique" is null', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -197,7 +197,7 @@ describe('PropertyUniquenessValidator', function () {
     });
 
     it('skips checking if the option "unique" is false', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -213,7 +213,7 @@ describe('PropertyUniquenessValidator', function () {
     });
 
     it('skips checking if the option "unique" is "nonUnique"', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -229,7 +229,7 @@ describe('PropertyUniquenessValidator', function () {
     });
 
     it('throws an error for unsupported method', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineModel({
         name: 'model',
         properties: {
@@ -250,7 +250,7 @@ describe('PropertyUniquenessValidator', function () {
     describe('the "unique" option is true', function () {
       describe('create', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -269,7 +269,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -284,7 +284,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for each unique property of the model', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -321,7 +321,7 @@ describe('PropertyUniquenessValidator', function () {
 
       describe('replaceById', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -346,7 +346,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -361,7 +361,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for each unique property of the model', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -409,7 +409,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('can use a custom primary key', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -449,7 +449,7 @@ describe('PropertyUniquenessValidator', function () {
 
       describe('replaceOrCreate', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -470,7 +470,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -485,7 +485,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for each unique property of the model', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -522,7 +522,7 @@ describe('PropertyUniquenessValidator', function () {
         describe('in case that the given model has a document identifier', function () {
           describe('a document of the given identifier does not exist', function () {
             it('uses the default primary key to check existence of the given identifier', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -555,7 +555,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('uses a custom primary key to check existence of the given identifier', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -593,7 +593,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('checks the given identifier only once', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -634,7 +634,7 @@ describe('PropertyUniquenessValidator', function () {
 
           describe('a document of the given identifier already exist', function () {
             it('uses the default primary key to check existence of the given identifier', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -676,7 +676,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('uses a custom primary key to check existence of the given identifier', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -720,7 +720,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('checks the given identifier only once', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -775,7 +775,7 @@ describe('PropertyUniquenessValidator', function () {
 
       describe('patch', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -794,7 +794,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -809,7 +809,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for given properties which should be unique', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -840,7 +840,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('skips uniqueness checking for non-provided fields', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -863,7 +863,7 @@ describe('PropertyUniquenessValidator', function () {
 
       describe('patchById', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -888,7 +888,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -903,7 +903,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for given properties which should be unique', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -945,7 +945,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('skips uniqueness checking for non-provided fields', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -970,7 +970,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('uses a custom primary key to check existence of the given identifier', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1012,7 +1012,7 @@ describe('PropertyUniquenessValidator', function () {
     describe('the "unique" option is "strict"', function () {
       describe('create', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1031,7 +1031,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1046,7 +1046,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for each unique property of the model', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1083,7 +1083,7 @@ describe('PropertyUniquenessValidator', function () {
 
       describe('replaceById', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1108,7 +1108,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1123,7 +1123,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for each unique property of the model', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1171,7 +1171,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('can use a custom primary key', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1211,7 +1211,7 @@ describe('PropertyUniquenessValidator', function () {
 
       describe('replaceOrCreate', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1232,7 +1232,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1247,7 +1247,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for each unique property of the model', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1284,7 +1284,7 @@ describe('PropertyUniquenessValidator', function () {
         describe('in case that the given model has a document identifier', function () {
           describe('a document of the given identifier does not exist', function () {
             it('uses the default primary key to check existence of the given identifier', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -1317,7 +1317,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('uses a custom primary key to check existence of the given identifier', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -1355,7 +1355,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('checks the given identifier only once', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -1396,7 +1396,7 @@ describe('PropertyUniquenessValidator', function () {
 
           describe('a document of the given identifier already exist', function () {
             it('uses the default primary key to check existence of the given identifier', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -1438,7 +1438,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('uses a custom primary key to check existence of the given identifier', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -1482,7 +1482,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('checks the given identifier only once', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -1537,7 +1537,7 @@ describe('PropertyUniquenessValidator', function () {
 
       describe('patch', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1556,7 +1556,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1571,7 +1571,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for given properties which should be unique', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1602,7 +1602,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('skips uniqueness checking for non-provided fields', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1625,7 +1625,7 @@ describe('PropertyUniquenessValidator', function () {
 
       describe('patchById', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1650,7 +1650,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1665,7 +1665,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for given properties which should be unique', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1707,7 +1707,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('skips uniqueness checking for non-provided fields', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1732,7 +1732,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('uses a custom primary key to check existence of the given identifier', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1774,7 +1774,7 @@ describe('PropertyUniquenessValidator', function () {
     describe('the "unique" option is "sparse"', function () {
       describe('create', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1793,7 +1793,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1808,7 +1808,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for given properties which should be unique', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1839,7 +1839,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('skips uniqueness checking for empty values', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1871,7 +1871,7 @@ describe('PropertyUniquenessValidator', function () {
 
       describe('replaceById', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1896,7 +1896,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1911,7 +1911,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for given properties which should be unique', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1953,7 +1953,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('skips uniqueness checking for empty values', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -1994,7 +1994,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('uses a custom primary key to check existence of the given identifier', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2034,7 +2034,7 @@ describe('PropertyUniquenessValidator', function () {
 
       describe('replaceOrCreate', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2055,7 +2055,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2070,7 +2070,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for given properties which should be unique', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2103,7 +2103,7 @@ describe('PropertyUniquenessValidator', function () {
         describe('in case that the given model has a document identifier', function () {
           describe('a document of the given identifier does not exist', function () {
             it('uses the default primary key to check existence of the given identifier', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -2136,7 +2136,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('uses a custom primary key to check existence of the given identifier', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -2174,7 +2174,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('checks the given identifier only once', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -2213,7 +2213,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('skips uniqueness checking for empty values', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -2255,7 +2255,7 @@ describe('PropertyUniquenessValidator', function () {
 
           describe('a document of the given identifier already exist', function () {
             it('uses the default primary key to check existence of the given identifier', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -2297,7 +2297,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('uses a custom primary key to check existence of the given identifier', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -2341,7 +2341,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('checks the given identifier only once', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -2392,7 +2392,7 @@ describe('PropertyUniquenessValidator', function () {
             });
 
             it('skips uniqueness checking for empty values', async function () {
-              const schema = new Schema();
+              const schema = new DatabaseSchema();
               schema.defineModel({
                 name: 'model',
                 properties: {
@@ -2440,7 +2440,7 @@ describe('PropertyUniquenessValidator', function () {
 
       describe('patch', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2459,7 +2459,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2474,7 +2474,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for given properties which should be unique', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2505,7 +2505,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('skips uniqueness checking for non-provided fields', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2526,7 +2526,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('skips uniqueness checking for empty values', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2558,7 +2558,7 @@ describe('PropertyUniquenessValidator', function () {
 
       describe('patchById', function () {
         it('throws an error if the "countMethod" returns a positive number', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2583,7 +2583,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('passes validation if the "countMethod" returns zero', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2598,7 +2598,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('invokes the "countMethod" for given properties which should be unique', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2640,7 +2640,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('skips uniqueness checking for non-provided fields', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2665,7 +2665,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('skips uniqueness checking for empty values', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {
@@ -2699,7 +2699,7 @@ describe('PropertyUniquenessValidator', function () {
         });
 
         it('uses a custom primary key to check existence of the given identifier', async function () {
-          const schema = new Schema();
+          const schema = new DatabaseSchema();
           schema.defineModel({
             name: 'model',
             properties: {

+ 2 - 2
src/filter/fields-clause-tool.spec.js

@@ -1,10 +1,10 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {format} from '@e22m4u/js-format';
+import {DatabaseSchema} from '../database-schema.js';
 import {FieldsClauseTool} from './fields-clause-tool.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
 
-const S = new Schema();
+const S = new DatabaseSchema();
 const MODEL_NAME = 'model';
 S.defineModel({name: MODEL_NAME});
 const T = S.getService(FieldsClauseTool);

+ 1 - 1
src/index.d.ts

@@ -1,9 +1,9 @@
 export * from './types.js';
-export * from './schema.js';
 export * from './utils/index.js';
 export * from './errors/index.js';
 export * from './filter/index.js';
 export * from './adapter/index.js';
+export * from './database-schema.js';
 export * from './relations/index.js';
 export * from './definition/index.js';
 export * from './repository/index.js';

+ 1 - 1
src/index.js

@@ -1,9 +1,9 @@
 export * from './types.js';
-export * from './schema.js';
 export * from './utils/index.js';
 export * from './errors/index.js';
 export * from './filter/index.js';
 export * from './adapter/index.js';
+export * from './database-schema.js';
 export * from './relations/index.js';
 export * from './definition/index.js';
 export * from './repository/index.js';

+ 37 - 37
src/relations/belongs-to-resolver.spec.js

@@ -1,15 +1,15 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {format} from '@e22m4u/js-format';
 import {DataType} from '../definition/index.js';
 import {RelationType} from '../definition/index.js';
+import {DatabaseSchema} from '../database-schema.js';
 import {BelongsToResolver} from './belongs-to-resolver.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
 
 describe('BelongsToResolver', function () {
   describe('includeTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -30,7 +30,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -51,7 +51,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -71,7 +71,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -91,7 +91,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -111,7 +111,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the provided parameter "foreignKey" to be a string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -128,7 +128,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -152,7 +152,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('throws an error if the given target model is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(BelongsToResolver);
       const promise = R.includeTo([], 'source', 'target', 'relation');
@@ -162,7 +162,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('throws an error if the given target model does not have a datasource', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'target'});
       const R = S.getService(BelongsToResolver);
       const promise = R.includeTo([], 'source', 'target', 'relation');
@@ -172,7 +172,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -187,7 +187,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if a primary key is not defined in the target model', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -210,7 +210,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -242,7 +242,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -274,7 +274,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if the property "foreignKey" is specified', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -297,7 +297,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -338,7 +338,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -375,7 +375,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -475,7 +475,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -523,7 +523,7 @@ describe('BelongsToResolver', function () {
 
   describe('includePolymorphicTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -544,7 +544,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -565,7 +565,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -586,7 +586,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -606,7 +606,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the provided parameter "foreignKey" to be a string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -623,7 +623,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the provided parameter "discriminator" to be a string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -640,7 +640,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(BelongsToResolver);
       const error = v =>
         format(
@@ -664,7 +664,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('does not throw an error if a target model is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(BelongsToResolver);
       const entity = {[DEF_PK]: 1, parentId: 1, parentType: 'target'};
@@ -673,7 +673,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('does not throws an error if a target model does not have datasource', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(BelongsToResolver);
@@ -683,7 +683,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -702,7 +702,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('does not throw an error if no discriminator value', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(BelongsToResolver);
       const entity = {[DEF_PK]: 1, parentId: 1};
@@ -711,7 +711,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if a primary key is not defined in the target model', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -739,7 +739,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -776,7 +776,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if the property "foreignKey" is specified', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -804,7 +804,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('includes if the property "discriminator" is specified', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -838,7 +838,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -893,7 +893,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -938,7 +938,7 @@ describe('BelongsToResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',

+ 60 - 60
src/relations/has-many-resolver.spec.js

@@ -1,15 +1,15 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {format} from '@e22m4u/js-format';
 import {DataType} from '../definition/index.js';
 import {RelationType} from '../definition/index.js';
+import {DatabaseSchema} from '../database-schema.js';
 import {HasManyResolver} from './has-many-resolver.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
 
 describe('HasManyResolver', function () {
   describe('includeTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -36,7 +36,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasManyResolver);
       const error = v =>
@@ -58,7 +58,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -79,7 +79,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -100,7 +100,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -121,7 +121,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "foreignKey" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -142,7 +142,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -166,7 +166,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if a target model is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasManyResolver);
       const promise = R.includeTo(
@@ -182,7 +182,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if a target model does not have datasource', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(HasManyResolver);
@@ -199,7 +199,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not throw an error if a relation target is not exist', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -214,7 +214,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if a primary key is not defined in the source model', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -255,7 +255,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -305,7 +305,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -355,7 +355,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -425,7 +425,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -488,7 +488,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -646,7 +646,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -721,7 +721,7 @@ describe('HasManyResolver', function () {
 
   describe('includePolymorphicTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -749,7 +749,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasManyResolver);
       const error = v =>
@@ -778,7 +778,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -806,7 +806,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -834,7 +834,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -862,7 +862,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "foreignKey" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -890,7 +890,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "discriminator" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -918,7 +918,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -943,7 +943,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the given target model is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasManyResolver);
       const entity = {[DEF_PK]: 1};
@@ -961,7 +961,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the given target model does not have a datasource', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(HasManyResolver);
@@ -980,7 +980,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1005,7 +1005,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not include an entity with a not matched discriminator value', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1040,7 +1040,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if a primary key is not defined in the source model', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1102,7 +1102,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -1173,7 +1173,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1244,7 +1244,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1335,7 +1335,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1410,7 +1410,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -1584,7 +1584,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1680,7 +1680,7 @@ describe('HasManyResolver', function () {
 
   describe('includePolymorphicByRelationName', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -1707,7 +1707,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1744,7 +1744,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -1771,7 +1771,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -1798,7 +1798,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -1825,7 +1825,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the "targetRelationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -1852,7 +1852,7 @@ describe('HasManyResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasManyResolver);
       const error = v =>
         format(
@@ -1876,7 +1876,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the given target model is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasManyResolver);
       const entity = {[DEF_PK]: 1};
@@ -1893,7 +1893,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the given target model does not have the given relation name', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(HasManyResolver);
@@ -1911,7 +1911,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the target relation is not "belongsTo"', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1939,7 +1939,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the target relation is not polymorphic', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1967,7 +1967,7 @@ describe('HasManyResolver', function () {
     });
 
     it('throws an error if the given target model does not have a datasource', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1993,7 +1993,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2026,7 +2026,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not include an entity with a not matched discriminator value', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2069,7 +2069,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if a primary key is not defined in the source model', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2139,7 +2139,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -2218,7 +2218,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2294,7 +2294,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the target model has a custom "foreignKey"', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2371,7 +2371,7 @@ describe('HasManyResolver', function () {
     });
 
     it('includes if the target model has a custom "discriminator"', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2448,7 +2448,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2546,7 +2546,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2629,7 +2629,7 @@ describe('HasManyResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -2808,7 +2808,7 @@ describe('HasManyResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({

+ 60 - 60
src/relations/has-one-resolver.spec.js

@@ -1,15 +1,15 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {format} from '@e22m4u/js-format';
 import {DataType} from '../definition/index.js';
 import {RelationType} from '../definition/index.js';
 import {HasOneResolver} from './has-one-resolver.js';
+import {DatabaseSchema} from '../database-schema.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
 
 describe('HasOneResolver', function () {
   describe('includeTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -36,7 +36,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasOneResolver);
       const error = v =>
@@ -58,7 +58,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -79,7 +79,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -100,7 +100,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -121,7 +121,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "foreignKey" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -142,7 +142,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -166,7 +166,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if a target model is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasOneResolver);
       const promise = R.includeTo(
@@ -182,7 +182,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if a target model does not have datasource', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(HasOneResolver);
@@ -199,7 +199,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not throw an error if a relation target is not exist', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -213,7 +213,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if a primary key is not defined in the source model', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -238,7 +238,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -272,7 +272,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -306,7 +306,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -358,7 +358,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -393,7 +393,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -495,7 +495,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -552,7 +552,7 @@ describe('HasOneResolver', function () {
 
   describe('includePolymorphicTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -580,7 +580,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasOneResolver);
       const error = v =>
@@ -609,7 +609,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -637,7 +637,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -665,7 +665,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -693,7 +693,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "foreignKey" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -721,7 +721,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "discriminator" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -749,7 +749,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -774,7 +774,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the given target model is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasOneResolver);
       const entity = {[DEF_PK]: 1};
@@ -792,7 +792,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the given target model does not have a datasource', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(HasOneResolver);
@@ -811,7 +811,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -835,7 +835,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not include an entity with a not matched discriminator value', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -869,7 +869,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if a primary key is not defined in the source model', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -906,7 +906,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -952,7 +952,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -998,7 +998,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1068,7 +1068,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1111,7 +1111,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -1227,7 +1227,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -1302,7 +1302,7 @@ describe('HasOneResolver', function () {
 
   describe('includePolymorphicByRelationName', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -1329,7 +1329,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1366,7 +1366,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -1393,7 +1393,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -1420,7 +1420,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -1447,7 +1447,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the "targetRelationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -1474,7 +1474,7 @@ describe('HasOneResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(HasOneResolver);
       const error = v =>
         format(
@@ -1498,7 +1498,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the given target model is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(HasOneResolver);
       const entity = {[DEF_PK]: 1};
@@ -1515,7 +1515,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the given target model does not have the given relation name', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({name: 'target'});
       const R = S.getService(HasOneResolver);
@@ -1533,7 +1533,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the target relation is not "belongsTo"', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1561,7 +1561,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the target relation is not polymorphic', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1589,7 +1589,7 @@ describe('HasOneResolver', function () {
     });
 
     it('throws an error if the given target model does not have a datasource', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       S.defineModel({
         name: 'target',
@@ -1615,7 +1615,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1647,7 +1647,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not include an entity with a not matched discriminator value', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1689,7 +1689,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if a primary key is not defined in the source model', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1734,7 +1734,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -1788,7 +1788,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1839,7 +1839,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the target model has a custom "foreignKey"', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1891,7 +1891,7 @@ describe('HasOneResolver', function () {
     });
 
     it('includes if the target model has a custom "discriminator"', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -1943,7 +1943,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2020,7 +2020,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -2071,7 +2071,7 @@ describe('HasOneResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -2192,7 +2192,7 @@ describe('HasOneResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({

+ 20 - 20
src/relations/references-many-resolver.spec.js

@@ -1,15 +1,15 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {format} from '@e22m4u/js-format';
 import {DataType} from '../definition/index.js';
 import {RelationType} from '../definition/index.js';
+import {DatabaseSchema} from '../database-schema.js';
 import {ReferencesManyResolver} from './references-many-resolver.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
 
 describe('ReferencesManyResolver', function () {
   describe('includeTo', function () {
     it('requires the "entities" parameter to be an array', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -30,7 +30,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('requires elements of the "entities" parameter to be an Object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -51,7 +51,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('requires the "sourceName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -71,7 +71,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('requires the "targetName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -91,7 +91,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('requires the "relationName" parameter to be a non-empty string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -111,7 +111,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('requires the provided parameter "foreignKey" to be a string', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -128,7 +128,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('requires the provided parameter "scope" to be an object', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       const R = S.getService(ReferencesManyResolver);
       const error = v =>
         format(
@@ -152,7 +152,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('throws an error if the given target model is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'source'});
       const R = S.getService(ReferencesManyResolver);
       const promise = R.includeTo([], 'source', 'target', 'relation');
@@ -162,7 +162,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('throws an error if the given target model does not have a datasource', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineModel({name: 'target'});
       const R = S.getService(ReferencesManyResolver);
       const promise = R.includeTo([], 'source', 'target', 'relation');
@@ -172,7 +172,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('does not throw an error if a relation target is not found', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -188,7 +188,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('includes if a primary key is not defined in the target model', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -217,7 +217,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('includes if the target model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({
@@ -255,7 +255,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('includes if the source model has a custom primary key', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({
         name: 'source',
@@ -293,7 +293,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('includes if the property "foreignKey" is specified', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -322,7 +322,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('uses a where clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -362,7 +362,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('uses a slice clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -406,7 +406,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('uses a fields clause of the given scope to filter the relation target', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});
@@ -467,7 +467,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('uses an include clause of the given scope to resolve target relations', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({
         name: 'datasource',
         adapter: 'memory',
@@ -589,7 +589,7 @@ describe('ReferencesManyResolver', function () {
     });
 
     it('does not break the "and" operator of the given "where" clause', async function () {
-      const S = new Schema();
+      const S = new DatabaseSchema();
       S.defineDatasource({name: 'datasource', adapter: 'memory'});
       S.defineModel({name: 'source', datasource: 'datasource'});
       S.defineModel({name: 'target', datasource: 'datasource'});

+ 3 - 3
src/repository/repository-registry.spec.js

@@ -1,13 +1,13 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
 import {Repository} from './repository.js';
+import {DatabaseSchema} from '../database-schema.js';
 import {RepositoryRegistry} from './repository-registry.js';
 
 describe('RepositoryRegistry', function () {
   describe('setRepositoryCtor', function () {
     it('sets a given class as the repository constructor', function () {
       class MyRepository extends Repository {}
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const registry = schema.getService(RepositoryRegistry);
@@ -20,7 +20,7 @@ describe('RepositoryRegistry', function () {
 
   describe('getRepository', function () {
     it('uses a given model name to return an existing repository or create the new', function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'modelA', datasource: 'datasource'});
       schema.defineModel({name: 'modelB', datasource: 'datasource'});

+ 19 - 19
src/repository/repository.spec.js

@@ -1,11 +1,11 @@
 import {expect} from 'chai';
-import {Schema} from '../schema.js';
+import {DatabaseSchema} from '../database-schema.js';
 import {DEFAULT_PRIMARY_KEY_PROPERTY_NAME as DEF_PK} from '../definition/index.js';
 
 describe('Repository', function () {
   describe('create', function () {
     it('creates a new item from the given data', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const data = {foo: 'bar'};
@@ -17,7 +17,7 @@ describe('Repository', function () {
 
   describe('replaceById', function () {
     it('replaces an item by the given id', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -29,7 +29,7 @@ describe('Repository', function () {
 
   describe('replaceOrCreate', function () {
     it('creates a new item from the given data', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const data = {foo: 'bar'};
@@ -39,7 +39,7 @@ describe('Repository', function () {
     });
 
     it('replaces an existing item', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -52,7 +52,7 @@ describe('Repository', function () {
 
   describe('patch', function () {
     it('patches all items', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -64,7 +64,7 @@ describe('Repository', function () {
     });
 
     it('patches found items by the "where" clause', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -78,7 +78,7 @@ describe('Repository', function () {
 
   describe('patchById', function () {
     it('patches an item by the given id', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -94,7 +94,7 @@ describe('Repository', function () {
 
   describe('find', function () {
     it('returns all items', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -105,7 +105,7 @@ describe('Repository', function () {
     });
 
     it('returns found items by the "where" clause', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -118,7 +118,7 @@ describe('Repository', function () {
 
   describe('findOne', function () {
     it('returns a first item', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -129,7 +129,7 @@ describe('Repository', function () {
     });
 
     it('returns a found item by the "where" clause', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -142,7 +142,7 @@ describe('Repository', function () {
 
   describe('findById', function () {
     it('returns an item by the given id', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -154,7 +154,7 @@ describe('Repository', function () {
 
   describe('delete', function () {
     it('removes all items', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -165,7 +165,7 @@ describe('Repository', function () {
     });
 
     it('removes found items by the "where" clause', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -179,7 +179,7 @@ describe('Repository', function () {
 
   describe('deleteById', function () {
     it('removes an item by the given id', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -191,7 +191,7 @@ describe('Repository', function () {
 
   describe('exists', function () {
     it('returns true if the given id exists', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -203,7 +203,7 @@ describe('Repository', function () {
 
   describe('count', function () {
     it('counts all items', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');
@@ -214,7 +214,7 @@ describe('Repository', function () {
     });
 
     it('counts found items by the "where" clause', async function () {
-      const schema = new Schema();
+      const schema = new DatabaseSchema();
       schema.defineDatasource({name: 'datasource', adapter: 'memory'});
       schema.defineModel({name: 'model', datasource: 'datasource'});
       const rep = schema.getRepository('model');

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