mythix-orm 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +94 -0
- package/.vscode/launch.json +34 -0
- package/.vscode/settings.json +10 -0
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/lib/connection/connection-base.js +877 -0
- package/lib/connection/index.js +11 -0
- package/lib/connection/literals/average-literal.js +14 -0
- package/lib/connection/literals/count-literal.js +18 -0
- package/lib/connection/literals/distinct-literal.js +14 -0
- package/lib/connection/literals/index.js +23 -0
- package/lib/connection/literals/literal-base.js +62 -0
- package/lib/connection/literals/literal-field-base.js +45 -0
- package/lib/connection/literals/literal.js +11 -0
- package/lib/connection/literals/max-literal.js +14 -0
- package/lib/connection/literals/min-literal.js +14 -0
- package/lib/connection/literals/sum-literal.js +14 -0
- package/lib/connection/query-generator-base.js +864 -0
- package/lib/errors/base-error.js +14 -0
- package/lib/errors/connection/access-denied-error.js +13 -0
- package/lib/errors/connection/connection-acquire-timeout-error.js +13 -0
- package/lib/errors/connection/connection-refused-error.js +13 -0
- package/lib/errors/connection/connection-timed-out-error.js +13 -0
- package/lib/errors/connection/host-not-found-error.js +13 -0
- package/lib/errors/connection/host-not-reachable-error.js +13 -0
- package/lib/errors/connection/index.js +19 -0
- package/lib/errors/connection/invalid-connection-error.js +13 -0
- package/lib/errors/connection-base-error.js +13 -0
- package/lib/errors/database/exclusion-constraint-error.js +13 -0
- package/lib/errors/database/foreign-key-constraint-error.js +13 -0
- package/lib/errors/database/index.js +13 -0
- package/lib/errors/database/timeout-error.js +13 -0
- package/lib/errors/database/unknown-constraint-error.js +13 -0
- package/lib/errors/database-base-error.js +17 -0
- package/lib/errors/index.js +44 -0
- package/lib/field.js +18 -0
- package/lib/index.js +43 -0
- package/lib/model.js +1374 -0
- package/lib/proxy-class/index.js +3 -0
- package/lib/proxy-class/proxy-class.js +269 -0
- package/lib/query-engine/field-scope.js +99 -0
- package/lib/query-engine/index.js +13 -0
- package/lib/query-engine/model-scope.js +198 -0
- package/lib/query-engine/query-engine-base.js +325 -0
- package/lib/query-engine/query-engine.js +212 -0
- package/lib/types/concrete/bigint-type.js +62 -0
- package/lib/types/concrete/blob-type.js +46 -0
- package/lib/types/concrete/boolean-type.js +41 -0
- package/lib/types/concrete/char-type.js +39 -0
- package/lib/types/concrete/date-type.js +87 -0
- package/lib/types/concrete/datetime-type.js +92 -0
- package/lib/types/concrete/float-type.js +47 -0
- package/lib/types/concrete/foreign-key-type.js +208 -0
- package/lib/types/concrete/index.js +53 -0
- package/lib/types/concrete/integer-type.js +51 -0
- package/lib/types/concrete/string-type.js +44 -0
- package/lib/types/concrete/text-type.js +44 -0
- package/lib/types/concrete/uuid-base.js +77 -0
- package/lib/types/concrete/uuid-v1-type.js +99 -0
- package/lib/types/concrete/uuid-v3-type.js +108 -0
- package/lib/types/concrete/uuid-v4-type.js +90 -0
- package/lib/types/concrete/uuid-v5-type.js +108 -0
- package/lib/types/concrete/xid-type.js +58 -0
- package/lib/types/helpers/default-helpers.js +127 -0
- package/lib/types/helpers/index.js +35 -0
- package/lib/types/index.js +94 -0
- package/lib/types/type.js +244 -0
- package/lib/types/virtual/index.js +14 -0
- package/lib/types/virtual/model-type.js +141 -0
- package/lib/types/virtual/models-type.js +264 -0
- package/lib/types/virtual/relational-type-base.js +323 -0
- package/lib/utils/index.js +65 -0
- package/lib/utils/misc-utils.js +73 -0
- package/lib/utils/model-utils.js +704 -0
- package/lib/utils/query-utils.js +186 -0
- package/package.json +63 -0
- package/playground/test01.js +15 -0
- package/spec/connection/connection-base-spec.js +126 -0
- package/spec/connection/literals/average-literal-spec.js +45 -0
- package/spec/connection/literals/count-literal-spec.js +42 -0
- package/spec/connection/literals/distinct-literal-spec.js +42 -0
- package/spec/connection/literals/literal-spec.js +26 -0
- package/spec/connection/literals/max-literal-spec.js +42 -0
- package/spec/connection/literals/min-literal-spec.js +42 -0
- package/spec/connection/literals/sum-literal-spec.js +42 -0
- package/spec/helpers/default-helpers-spec.js +108 -0
- package/spec/model-spec.js +736 -0
- package/spec/proxy-class/proxy-class-spec.js +173 -0
- package/spec/query-engine/__snapshots__/QueryEngine-operations-query_operations_and_chaining-can_chain_query_conditions-001.snapshot +94 -0
- package/spec/query-engine/__snapshots__/QueryEngine-operations-query_operations_and_chaining-can_construct_a_query_context_with_a_model_call-001.snapshot +35 -0
- package/spec/query-engine/__snapshots__/QueryEngine-operations-query_operations_and_chaining-can_construct_a_query_context_with_a_model_sub-001.snapshot +35 -0
- package/spec/query-engine/__snapshots__/QueryEngine-operations-query_operations_and_chaining-can_set_a_default_scope_on_a_model-001.snapshot +57 -0
- package/spec/query-engine/__snapshots__/QueryEngine-operations-query_operations_and_chaining-can_unscope_default_scope_on_a_model-001.snapshot +35 -0
- package/spec/query-engine/query-engine-spec.js +99 -0
- package/spec/support/jasmine.json +13 -0
- package/spec/support/models/blob-test-model.js +19 -0
- package/spec/support/models/extended-user-model.js +38 -0
- package/spec/support/models/index.js +27 -0
- package/spec/support/models/number-model.js +24 -0
- package/spec/support/models/role-model.js +26 -0
- package/spec/support/models/role-thing-model.js +41 -0
- package/spec/support/models/scoped-user-model.js +13 -0
- package/spec/support/models/time-model.js +36 -0
- package/spec/support/models/user-model.js +70 -0
- package/spec/support/models/user-role-model.js +36 -0
- package/spec/support/models/user-thing-model.js +46 -0
- package/spec/support/models/validation-test-model.js +40 -0
- package/spec/support/snapshots.js +293 -0
- package/spec/support/test-helpers.js +13 -0
- package/spec/types/concrete/bigint-type-spec.js +84 -0
- package/spec/types/concrete/boolean-type-spec.js +83 -0
- package/spec/types/concrete/date-type-spec.js +85 -0
- package/spec/types/concrete/datetime-type-spec.js +87 -0
- package/spec/types/concrete/float-type-spec.js +71 -0
- package/spec/types/concrete/foreign-key-type-spec.js +64 -0
- package/spec/types/concrete/integer-type-spec.js +71 -0
- package/spec/types/concrete/string-type-spec.js +91 -0
- package/spec/types/concrete/uuid-v1-type-spec.js +73 -0
- package/spec/types/concrete/uuid-v4-type-spec.js +65 -0
- package/spec/types/type-spec.js +101 -0
- package/spec/types/virtual/model-types-spec.js +401 -0
- package/spec/utils/misc-utils-spec.js +61 -0
- package/spec/utils/model-utils-spec.js +55 -0
- package/spec/utils/query-utils-spec.js +105 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable no-magic-numbers */
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
'env': {
|
|
7
|
+
'browser': true,
|
|
8
|
+
'commonjs': true,
|
|
9
|
+
'es2021': true,
|
|
10
|
+
},
|
|
11
|
+
'extends': [
|
|
12
|
+
'eslint:recommended',
|
|
13
|
+
],
|
|
14
|
+
'parserOptions': {
|
|
15
|
+
'ecmaVersion': 'latest',
|
|
16
|
+
},
|
|
17
|
+
'plugins': [
|
|
18
|
+
'@spothero/eslint-plugin-spothero',
|
|
19
|
+
],
|
|
20
|
+
'rules': {
|
|
21
|
+
'@spothero/spothero/ternary-parentheses': 'error',
|
|
22
|
+
'arrow-parens': 'error',
|
|
23
|
+
'arrow-spacing': [ 'error', { before: true, after: true } ],
|
|
24
|
+
'block-scoped-var': 'warn',
|
|
25
|
+
'block-spacing': 'error',
|
|
26
|
+
'brace-style': [ 'error', '1tbs' ],
|
|
27
|
+
'camelcase': 'warn',
|
|
28
|
+
'comma-dangle': [ 'error', 'always-multiline' ],
|
|
29
|
+
'comma-spacing': [ 'error', { before: false, after: true } ],
|
|
30
|
+
'comma-style': [ 'error', 'last' ],
|
|
31
|
+
'curly': [ 'error', 'multi-or-nest', 'consistent' ],
|
|
32
|
+
'default-case-last': 'error',
|
|
33
|
+
'default-param-last': 'error',
|
|
34
|
+
'eqeqeq': [ 'error', 'smart' ],
|
|
35
|
+
'func-call-spacing': [ 'error', 'never' ],
|
|
36
|
+
'guard-for-in': 'error',
|
|
37
|
+
'implicit-arrow-linebreak': [ 'error', 'beside' ],
|
|
38
|
+
'indent': [ 'error', 2, { 'SwitchCase': 1, 'MemberExpression': 'off' } ],
|
|
39
|
+
'jsx-quotes': [ 'error', 'prefer-double' ],
|
|
40
|
+
'key-spacing': [ 'error', { beforeColon: false, afterColon: true, mode: 'minimum', 'align': 'value' } ],
|
|
41
|
+
'keyword-spacing': [ 'error', { before: true, after: true } ],
|
|
42
|
+
'linebreak-style': [ 'error', 'unix' ],
|
|
43
|
+
'lines-between-class-members': 'error',
|
|
44
|
+
'max-classes-per-file': [ 'error', 3 ],
|
|
45
|
+
'new-cap': [ 'error', { 'properties': false } ],
|
|
46
|
+
'new-parens': 'error',
|
|
47
|
+
'no-array-constructor': 'warn',
|
|
48
|
+
'no-caller': 'error',
|
|
49
|
+
'no-confusing-arrow': 'error',
|
|
50
|
+
'no-empty': 'warn',
|
|
51
|
+
'no-eq-null': 0,
|
|
52
|
+
'no-eval': 'error',
|
|
53
|
+
'no-extend-native': 'error',
|
|
54
|
+
'no-extra-label': 'error',
|
|
55
|
+
'no-floating-decimal': 'error',
|
|
56
|
+
'no-global-assign': 'error',
|
|
57
|
+
'no-implied-eval': 'error',
|
|
58
|
+
'no-labels': 'error',
|
|
59
|
+
'no-lone-blocks': 'warn',
|
|
60
|
+
'no-loop-func': 0,
|
|
61
|
+
'no-magic-numbers': [ 'warn', { ignoreArrayIndexes: true, ignoreDefaultValues: true, ignore: [ -1, 0, 1, 2, 16, 32, 64, 128, 256, 1024, 2048, 200, 301, 302, 400, 401, 404, 500 ] } ],
|
|
62
|
+
'no-nested-ternary': 'error',
|
|
63
|
+
'no-param-reassign': 'error',
|
|
64
|
+
'no-promise-executor-return': 'error',
|
|
65
|
+
'no-return-assign': 'error',
|
|
66
|
+
'no-sequences': 'error',
|
|
67
|
+
'no-shadow': 0,
|
|
68
|
+
'no-throw-literal': 'warn',
|
|
69
|
+
'no-trailing-spaces': 'error',
|
|
70
|
+
'no-unmodified-loop-condition': 'warn',
|
|
71
|
+
'no-unreachable-loop': 'warn',
|
|
72
|
+
'no-unreachable': 'warn',
|
|
73
|
+
'no-unused-private-class-members': 'warn',
|
|
74
|
+
'no-unused-vars': 'warn',
|
|
75
|
+
'no-whitespace-before-property': 'error',
|
|
76
|
+
'nonblock-statement-body-position': [ 'error', 'below' ],
|
|
77
|
+
'one-var': [ 'error', 'never' ],
|
|
78
|
+
'quotes': [ 'error', 'single' ],
|
|
79
|
+
'radix': 'error',
|
|
80
|
+
'rest-spread-spacing': [ 'error', 'never' ],
|
|
81
|
+
'semi-spacing': [ 'error', { before: false, after: true } ],
|
|
82
|
+
'semi-style': [ 'error', 'last' ],
|
|
83
|
+
'semi': 'error',
|
|
84
|
+
'space-before-blocks': 'error',
|
|
85
|
+
'space-infix-ops': 'error',
|
|
86
|
+
'space-unary-ops': [ 'error', { words: false, nonwords: false } ],
|
|
87
|
+
'strict': 'error',
|
|
88
|
+
'switch-colon-spacing': [ 'error', { before: false, after: true } ],
|
|
89
|
+
'template-curly-spacing': 'error',
|
|
90
|
+
'template-tag-spacing': 'error',
|
|
91
|
+
'wrap-iife': [ 'error', 'inside' ],
|
|
92
|
+
'yoda': 'error',
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Use IntelliSense to learn about possible attributes.
|
|
3
|
+
// Hover to view descriptions of existing attributes.
|
|
4
|
+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
|
+
"version": "0.2.0",
|
|
6
|
+
"configurations": [
|
|
7
|
+
{
|
|
8
|
+
"type": "pwa-node",
|
|
9
|
+
"request": "launch",
|
|
10
|
+
"name": "Debug Unit Tests",
|
|
11
|
+
"skipFiles": [
|
|
12
|
+
"<node_internals>/**",
|
|
13
|
+
"node_modules/**/*.js",
|
|
14
|
+
"**/node_modules/**",
|
|
15
|
+
"async_hooks.js",
|
|
16
|
+
"inspector_async_hook.js"
|
|
17
|
+
],
|
|
18
|
+
"program": "${workspaceFolder}/node_modules/.bin/jasmine",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"type": "pwa-node",
|
|
22
|
+
"request": "launch",
|
|
23
|
+
"name": "Playground Test 01",
|
|
24
|
+
"skipFiles": [
|
|
25
|
+
"<node_internals>/**",
|
|
26
|
+
"node_modules/**/*.js",
|
|
27
|
+
"**/node_modules/**",
|
|
28
|
+
"async_hooks.js",
|
|
29
|
+
"inspector_async_hook.js"
|
|
30
|
+
],
|
|
31
|
+
"program": "${workspaceFolder}/playground/test01.js",
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Wyatt Greenway
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# mythix-orm
|
|
2
|
+
|
|
3
|
+
ORM for Mythix framework
|
|
4
|
+
|
|
5
|
+
Mythix ORM aims to replace Sequelize and the few other terrible solutions that the poor destitute Node community has to work with. Mythix ORM is not yet quite ready for prime time however, so please check back soon!
|
|
6
|
+
|
|
7
|
+
What to expect while you are waiting:
|
|
8
|
+
1. Advanced, seamless, and powerful (yet simple) query engine that is easy to use, and works across database drivers, even for No-SQL databases. Here is a simple example to fetch users and their roles: `let users = await User.where.id.EQ(Role.where.userID).firstName.EQ('Mythix').lastName.EQ('ORM').Roles.name.EQ('superuser').PROJECT('User', 'Role').all();`
|
|
9
|
+
2. Powerful model classes and helpers that don't violate good design patterns, stay out of your face, and have no undocumented auto-magic built in. The model system is also designed to work seamlessly across different databases, including No-SQL databases.
|
|
10
|
+
3. Simple, clean, and slim... Mythix ORM isn't intended to be a sledge hammer, nor a 'batteries included' framework. Instead, it is designed to be a useful tool, and was designed to be easily extended. It can be used for large enterprise applications, or it can be used as a simple slim layer to interact with different databases in a human-friendly way.
|
|
11
|
+
4. Mythix ORM is modular by design. Instead of being a large bloated library that attempts to handle every database and every type of operation, it instead only provides exactly what you need. Mythix ORM is itself just a base connection, a query engine, and a model and type system. That is all. To interact with databases you can choose between any number of drivers for Mythix ORM, and can use community built plugins for adding features (or simply write your own!).
|
|
12
|
+
5. Mythix ORM is designed from the ground-up to be extended/modified. Want to change the nature of the Query Engine? Just extend from it and away you go! Want to change the way models behave? No problem! Want to make your own connection? Go for it! Want to add your own custom data types for models? Super easy. Every part of Mythix ORM is designed to be swapped out in a non-global way so that its feature set can be extended and added onto.
|
|
13
|
+
6. Has complete feature parity (and soon greater functionality) then all existing ORMs for Node. Model validation, hooks, model attributes and data types, model relations, support for multiple databases, an advanced query engine, transactions, transactions inside transactions, useful utility methods, an extensible type system, virtual types, an extensible query generator, support for older Node versions, support for multiple connections and multiplex connections (at the same time), and more!
|
|
14
|
+
|
|
15
|
+
Stay tuned! Mythix ORM should be released and fully documented by Q1 of 2023!
|