mythix-orm 1.13.1 → 1.13.3
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/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# mythix-orm
|
|
2
2
|
|
|
3
|
-
Mythix
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Mythix ORM aims to replace Sequelize, Prisma, and the few other terrible solutions that the poor destitute Node community has to work with. Mythix ORM has been designed to replace all current ORMs for Node, with a focus on what is lacking in the community, namely good engineering, good documentation, and ease of use.
|
|
4
6
|
|
|
5
7
|
Mythix ORMs feature set includes:
|
|
6
8
|
1. An advanced, seamless, and powerful (yet simple) query engine that is easy to use, and works across database drivers, even for No-SQL databases.
|
|
@@ -28,7 +30,7 @@ Just start creating models!
|
|
|
28
30
|
|
|
29
31
|
```javascript
|
|
30
32
|
const { Model, Types } = require('mythix-orm');
|
|
31
|
-
const SQLiteConnection = require('mythix-orm-sqlite');
|
|
33
|
+
const { SQLiteConnection } = require('mythix-orm-sqlite');
|
|
32
34
|
|
|
33
35
|
class User extends Model {
|
|
34
36
|
static fields = {
|
|
@@ -97,10 +99,10 @@ class User extends Model {
|
|
|
97
99
|
|
|
98
100
|
## Notes
|
|
99
101
|
|
|
100
|
-
1. The [WIKI](https://github.com/th317erd/mythix-orm/wiki) is still being worked on. Most of the documentation is complete, but there is still a lot more to write. Documentation is the main focus right now.
|
|
102
|
+
1. The [WIKI](https://github.com/th317erd/mythix-orm/wiki) is still being worked on. Most of the documentation is complete, but there is still a lot more to write. Documentation is the main focus right now. If you have any questions, feel free to drop a line, or open an issue! We will be happy to answer any questions. We aren't "done" until our documentation is pristine. Feel free to drop us a line in our [Discord](https://discord.gg/DZsAYvym9N) server if you need assistance.
|
|
101
103
|
2. Right now there are only database drivers for [SQLite](https://www.npmjs.com/package/mythix-orm-sqlite) and [PostgreSQL](https://www.npmjs.com/package/mythix-orm-postgresql). More are planned, with a Mongo driver likely to land next, followed by MySQL. Help wanted!
|
|
102
104
|
3. Check out the [Mythix](https://www.npmjs.com/package/mythix) web-app framework. It is also still in active development, and the documentation is poor (to say the least), but it is up and coming, and will soon have fantastic documentation, and even though still in active development is fully functional. To get started try `npx mythix-cli create 'Test App'`
|
|
103
105
|
|
|
104
106
|
## Goals
|
|
105
107
|
|
|
106
|
-
The `Mythix` suite of technologies are being developed to give a rock-solid full-stack to build web-apps on Node. I got tired of the piecemeal garbage that currently exist in the Node ecosystem for building apps. My end goal is to have `Mythix` technologies take the Node community by storm, providing top-notch technologies for developers to create amazing things. Get involved with me, and let's change the world for the better!
|
|
108
|
+
The `Mythix` suite of technologies are being developed to give a rock-solid full-stack framework to build web-apps on Node. I got tired of the piecemeal garbage that currently exist in the Node ecosystem for building apps. My end goal is to have `Mythix` technologies take the Node community by storm, providing top-notch technologies for developers to create amazing things. Get involved with me, and let's change the world for the better!
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
const Nife = require('nife');
|
|
4
|
+
|
|
3
5
|
/// The base query generator class.
|
|
4
6
|
///
|
|
5
7
|
/// A "query generator" is an interface that will take
|
|
@@ -339,6 +341,69 @@ class QueryGeneratorBase {
|
|
|
339
341
|
// eslint-disable-next-line no-unused-vars
|
|
340
342
|
getFieldDefaultValue(field, fieldName, _options) {
|
|
341
343
|
}
|
|
344
|
+
|
|
345
|
+
/// Take a <see>Field</see> instance, and generate
|
|
346
|
+
/// all index fields for this `field`.
|
|
347
|
+
///
|
|
348
|
+
/// The `index` property on a <see>Field</see> is used
|
|
349
|
+
/// to generate indexes for the field. If a `true` value
|
|
350
|
+
/// is encountered in the `index`, it means "this field".
|
|
351
|
+
/// If another field name is encountered in the `index` property,
|
|
352
|
+
/// then that means "combine this field with the specified field"
|
|
353
|
+
/// (to create a combined index). Take the following example:
|
|
354
|
+
/// ```javascript
|
|
355
|
+
/// ...
|
|
356
|
+
/// firstName: {
|
|
357
|
+
/// ...
|
|
358
|
+
/// index: [
|
|
359
|
+
/// true,
|
|
360
|
+
/// 'lastName',
|
|
361
|
+
/// [ 'email', 'lastName' ],
|
|
362
|
+
/// ]
|
|
363
|
+
/// }
|
|
364
|
+
/// ...
|
|
365
|
+
/// ```
|
|
366
|
+
/// This will create three indexes for this "firstName" column in the database:
|
|
367
|
+
/// 1) `true` = Index the `firstName` column by itself (`idx_users_firstName`)
|
|
368
|
+
/// 2) `lastName` = Combine `firstName` and `lastName` to create a combined index (`idx_users_firstName_lastName`)
|
|
369
|
+
/// 3) `[ 'email', 'lastName' ]` = Combine `firstName` with `email` and `lastName` to create a combined index involving three columns (`idx_users_firstName_email_lastName`)
|
|
370
|
+
/// Using the above example, this method would return the following:
|
|
371
|
+
/// ```javascript
|
|
372
|
+
/// [
|
|
373
|
+
/// [ 'firstName' ],
|
|
374
|
+
/// [ 'firstName', 'lastName' ],
|
|
375
|
+
/// [ 'firstName', 'email', 'lastName' ],
|
|
376
|
+
/// ]
|
|
377
|
+
/// ```
|
|
378
|
+
/// Which is the list of indexes, and the fields to index for each index.
|
|
379
|
+
///
|
|
380
|
+
/// Arguments:
|
|
381
|
+
/// field: <see>Field</see>
|
|
382
|
+
/// The field used to pull the `index` property from.
|
|
383
|
+
///
|
|
384
|
+
/// Return: Array<Array<string>>
|
|
385
|
+
/// Return an array of arrays, where the top-level array lists the
|
|
386
|
+
/// indexes, and each sub-array lists the fields to combine into an
|
|
387
|
+
/// index.
|
|
388
|
+
getIndexFieldsFromFieldIndex(field) {
|
|
389
|
+
let indexes = Nife.toArray(field.index).filter((index) => {
|
|
390
|
+
if (index === true)
|
|
391
|
+
return true;
|
|
392
|
+
|
|
393
|
+
return (Nife.instanceOf(index, 'string', 'array') && Nife.isNotEmpty(index));
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
if (indexes.length === 0)
|
|
397
|
+
return [];
|
|
398
|
+
|
|
399
|
+
return indexes.map((indexNames) => {
|
|
400
|
+
let fieldIndexNames = [ field.fieldName ];
|
|
401
|
+
if (indexNames !== true)
|
|
402
|
+
fieldIndexNames = fieldIndexNames.concat(indexNames);
|
|
403
|
+
|
|
404
|
+
return fieldIndexNames;
|
|
405
|
+
});
|
|
406
|
+
}
|
|
342
407
|
}
|
|
343
408
|
|
|
344
409
|
module.exports = QueryGeneratorBase;
|
package/lib/utils/query-utils.js
CHANGED
|
@@ -118,6 +118,7 @@ function parseFilterFieldAndOperator(fieldName) {
|
|
|
118
118
|
/// Operators that can be postfixed to field names
|
|
119
119
|
/// in the provided `filter` object are as follows:
|
|
120
120
|
/// | Operator | Description |
|
|
121
|
+
/// | -------- | ----------- |
|
|
121
122
|
/// | `=` | Equality operator. If an `Array` of values is provided, then this will turn into a `IN` operation in the underlying database. |
|
|
122
123
|
/// | `!=` | Inverse (not) equality operator. If an `Array` of values is provided, then this will turn into a `NOT IN` operation in the underlying database. |
|
|
123
124
|
/// | `>` | Greater than operator. |
|