@getstrata/core 0.5.8 → 0.5.9
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/dist/entries/auth/guard.js +14 -14
- package/dist/entries/database.js +14 -14
- package/dist/entries/http/webErrorResponse.js +14 -14
- package/dist/entries/http.js +14 -14
- package/dist/entries/queue/createAppQueue.js +14 -14
- package/dist/entries/queue/publicQueue.js +14 -14
- package/dist/entries/queue/queueMetrics.js +14 -14
- package/dist/entries/view.js +14 -14
- package/dist/index.js +14 -14
- package/package.json +1 -1
|
@@ -1573,8 +1573,8 @@ class Model {
|
|
|
1573
1573
|
static boot() {}
|
|
1574
1574
|
static addGlobalScope(_name, scope) {
|
|
1575
1575
|
ensureBooted(this);
|
|
1576
|
-
const existing = modelGlobalScopes.get(
|
|
1577
|
-
modelGlobalScopes.set(
|
|
1576
|
+
const existing = modelGlobalScopes.get(this) ?? [];
|
|
1577
|
+
modelGlobalScopes.set(this, [
|
|
1578
1578
|
...existing,
|
|
1579
1579
|
scope
|
|
1580
1580
|
]);
|
|
@@ -1584,17 +1584,17 @@ class Model {
|
|
|
1584
1584
|
}
|
|
1585
1585
|
static query() {
|
|
1586
1586
|
ensureBooted(this);
|
|
1587
|
-
const repository = resolveModelRepository(
|
|
1587
|
+
const repository = resolveModelRepository(this);
|
|
1588
1588
|
let query = repository.query();
|
|
1589
|
-
for (const scope of getGlobalScopes(
|
|
1589
|
+
for (const scope of getGlobalScopes(this)) {
|
|
1590
1590
|
query = scope(query);
|
|
1591
1591
|
}
|
|
1592
1592
|
return query;
|
|
1593
1593
|
}
|
|
1594
1594
|
static async create(attributes) {
|
|
1595
1595
|
const statics = modelStatics(this);
|
|
1596
|
-
ensureBooted(
|
|
1597
|
-
const repository = resolveModelRepository(
|
|
1596
|
+
ensureBooted(this);
|
|
1597
|
+
const repository = resolveModelRepository(this);
|
|
1598
1598
|
const table = repository.getTable();
|
|
1599
1599
|
const timestamps = statics.$timestamps ?? true;
|
|
1600
1600
|
const assignable = filterMassAssignable(statics.$fillable, statics.$guarded, attributes);
|
|
@@ -1605,22 +1605,22 @@ class Model {
|
|
|
1605
1605
|
}
|
|
1606
1606
|
static async find(id) {
|
|
1607
1607
|
const statics = modelStatics(this);
|
|
1608
|
-
const repository = resolveModelRepository(
|
|
1608
|
+
const repository = resolveModelRepository(this);
|
|
1609
1609
|
const primaryKey = repository.getTable().primaryKey;
|
|
1610
|
-
const record = await Model.query.call(
|
|
1610
|
+
const record = await Model.query.call(this).where({ [primaryKey]: id }).first();
|
|
1611
1611
|
return record ? statics.fromRecord(record, repository, true) : null;
|
|
1612
1612
|
}
|
|
1613
1613
|
static async findOrFail(id, errorFactory) {
|
|
1614
|
-
const model = await Model.find.call(
|
|
1614
|
+
const model = await Model.find.call(this, id);
|
|
1615
1615
|
if (model) {
|
|
1616
1616
|
return model;
|
|
1617
1617
|
}
|
|
1618
|
-
throw errorFactory?.(id) ?? new NotFoundError(`${
|
|
1618
|
+
throw errorFactory?.(id) ?? new NotFoundError(`${this.name} ${String(id)} not found.`);
|
|
1619
1619
|
}
|
|
1620
1620
|
static async all(options = {}) {
|
|
1621
1621
|
const statics = modelStatics(this);
|
|
1622
|
-
const repository = resolveModelRepository(
|
|
1623
|
-
let query = Model.query.call(
|
|
1622
|
+
const repository = resolveModelRepository(this);
|
|
1623
|
+
let query = Model.query.call(this);
|
|
1624
1624
|
if (options.orderBy) {
|
|
1625
1625
|
query = query.orderBy(options.orderBy);
|
|
1626
1626
|
}
|
|
@@ -1632,8 +1632,8 @@ class Model {
|
|
|
1632
1632
|
}
|
|
1633
1633
|
static async firstWhere(where, options = {}) {
|
|
1634
1634
|
const statics = modelStatics(this);
|
|
1635
|
-
const repository = resolveModelRepository(
|
|
1636
|
-
let query = Model.query.call(
|
|
1635
|
+
const repository = resolveModelRepository(this);
|
|
1636
|
+
let query = Model.query.call(this).where(where);
|
|
1637
1637
|
if (options.orderBy) {
|
|
1638
1638
|
query = query.orderBy(options.orderBy);
|
|
1639
1639
|
}
|
package/dist/entries/database.js
CHANGED
|
@@ -1371,8 +1371,8 @@ class Model {
|
|
|
1371
1371
|
static boot() {}
|
|
1372
1372
|
static addGlobalScope(_name, scope) {
|
|
1373
1373
|
ensureBooted(this);
|
|
1374
|
-
const existing = modelGlobalScopes.get(
|
|
1375
|
-
modelGlobalScopes.set(
|
|
1374
|
+
const existing = modelGlobalScopes.get(this) ?? [];
|
|
1375
|
+
modelGlobalScopes.set(this, [
|
|
1376
1376
|
...existing,
|
|
1377
1377
|
scope
|
|
1378
1378
|
]);
|
|
@@ -1382,17 +1382,17 @@ class Model {
|
|
|
1382
1382
|
}
|
|
1383
1383
|
static query() {
|
|
1384
1384
|
ensureBooted(this);
|
|
1385
|
-
const repository = resolveModelRepository(
|
|
1385
|
+
const repository = resolveModelRepository(this);
|
|
1386
1386
|
let query = repository.query();
|
|
1387
|
-
for (const scope of getGlobalScopes(
|
|
1387
|
+
for (const scope of getGlobalScopes(this)) {
|
|
1388
1388
|
query = scope(query);
|
|
1389
1389
|
}
|
|
1390
1390
|
return query;
|
|
1391
1391
|
}
|
|
1392
1392
|
static async create(attributes) {
|
|
1393
1393
|
const statics = modelStatics(this);
|
|
1394
|
-
ensureBooted(
|
|
1395
|
-
const repository = resolveModelRepository(
|
|
1394
|
+
ensureBooted(this);
|
|
1395
|
+
const repository = resolveModelRepository(this);
|
|
1396
1396
|
const table = repository.getTable();
|
|
1397
1397
|
const timestamps = statics.$timestamps ?? true;
|
|
1398
1398
|
const assignable = filterMassAssignable(statics.$fillable, statics.$guarded, attributes);
|
|
@@ -1403,22 +1403,22 @@ class Model {
|
|
|
1403
1403
|
}
|
|
1404
1404
|
static async find(id) {
|
|
1405
1405
|
const statics = modelStatics(this);
|
|
1406
|
-
const repository = resolveModelRepository(
|
|
1406
|
+
const repository = resolveModelRepository(this);
|
|
1407
1407
|
const primaryKey = repository.getTable().primaryKey;
|
|
1408
|
-
const record = await Model.query.call(
|
|
1408
|
+
const record = await Model.query.call(this).where({ [primaryKey]: id }).first();
|
|
1409
1409
|
return record ? statics.fromRecord(record, repository, true) : null;
|
|
1410
1410
|
}
|
|
1411
1411
|
static async findOrFail(id, errorFactory) {
|
|
1412
|
-
const model = await Model.find.call(
|
|
1412
|
+
const model = await Model.find.call(this, id);
|
|
1413
1413
|
if (model) {
|
|
1414
1414
|
return model;
|
|
1415
1415
|
}
|
|
1416
|
-
throw errorFactory?.(id) ?? new NotFoundError(`${
|
|
1416
|
+
throw errorFactory?.(id) ?? new NotFoundError(`${this.name} ${String(id)} not found.`);
|
|
1417
1417
|
}
|
|
1418
1418
|
static async all(options = {}) {
|
|
1419
1419
|
const statics = modelStatics(this);
|
|
1420
|
-
const repository = resolveModelRepository(
|
|
1421
|
-
let query = Model.query.call(
|
|
1420
|
+
const repository = resolveModelRepository(this);
|
|
1421
|
+
let query = Model.query.call(this);
|
|
1422
1422
|
if (options.orderBy) {
|
|
1423
1423
|
query = query.orderBy(options.orderBy);
|
|
1424
1424
|
}
|
|
@@ -1430,8 +1430,8 @@ class Model {
|
|
|
1430
1430
|
}
|
|
1431
1431
|
static async firstWhere(where, options = {}) {
|
|
1432
1432
|
const statics = modelStatics(this);
|
|
1433
|
-
const repository = resolveModelRepository(
|
|
1434
|
-
let query = Model.query.call(
|
|
1433
|
+
const repository = resolveModelRepository(this);
|
|
1434
|
+
let query = Model.query.call(this).where(where);
|
|
1435
1435
|
if (options.orderBy) {
|
|
1436
1436
|
query = query.orderBy(options.orderBy);
|
|
1437
1437
|
}
|
|
@@ -1595,8 +1595,8 @@ class Model {
|
|
|
1595
1595
|
static boot() {}
|
|
1596
1596
|
static addGlobalScope(_name, scope) {
|
|
1597
1597
|
ensureBooted(this);
|
|
1598
|
-
const existing = modelGlobalScopes.get(
|
|
1599
|
-
modelGlobalScopes.set(
|
|
1598
|
+
const existing = modelGlobalScopes.get(this) ?? [];
|
|
1599
|
+
modelGlobalScopes.set(this, [
|
|
1600
1600
|
...existing,
|
|
1601
1601
|
scope
|
|
1602
1602
|
]);
|
|
@@ -1606,17 +1606,17 @@ class Model {
|
|
|
1606
1606
|
}
|
|
1607
1607
|
static query() {
|
|
1608
1608
|
ensureBooted(this);
|
|
1609
|
-
const repository = resolveModelRepository(
|
|
1609
|
+
const repository = resolveModelRepository(this);
|
|
1610
1610
|
let query = repository.query();
|
|
1611
|
-
for (const scope of getGlobalScopes(
|
|
1611
|
+
for (const scope of getGlobalScopes(this)) {
|
|
1612
1612
|
query = scope(query);
|
|
1613
1613
|
}
|
|
1614
1614
|
return query;
|
|
1615
1615
|
}
|
|
1616
1616
|
static async create(attributes) {
|
|
1617
1617
|
const statics = modelStatics(this);
|
|
1618
|
-
ensureBooted(
|
|
1619
|
-
const repository = resolveModelRepository(
|
|
1618
|
+
ensureBooted(this);
|
|
1619
|
+
const repository = resolveModelRepository(this);
|
|
1620
1620
|
const table = repository.getTable();
|
|
1621
1621
|
const timestamps = statics.$timestamps ?? true;
|
|
1622
1622
|
const assignable = filterMassAssignable(statics.$fillable, statics.$guarded, attributes);
|
|
@@ -1627,22 +1627,22 @@ class Model {
|
|
|
1627
1627
|
}
|
|
1628
1628
|
static async find(id) {
|
|
1629
1629
|
const statics = modelStatics(this);
|
|
1630
|
-
const repository = resolveModelRepository(
|
|
1630
|
+
const repository = resolveModelRepository(this);
|
|
1631
1631
|
const primaryKey = repository.getTable().primaryKey;
|
|
1632
|
-
const record = await Model.query.call(
|
|
1632
|
+
const record = await Model.query.call(this).where({ [primaryKey]: id }).first();
|
|
1633
1633
|
return record ? statics.fromRecord(record, repository, true) : null;
|
|
1634
1634
|
}
|
|
1635
1635
|
static async findOrFail(id, errorFactory) {
|
|
1636
|
-
const model = await Model.find.call(
|
|
1636
|
+
const model = await Model.find.call(this, id);
|
|
1637
1637
|
if (model) {
|
|
1638
1638
|
return model;
|
|
1639
1639
|
}
|
|
1640
|
-
throw errorFactory?.(id) ?? new NotFoundError(`${
|
|
1640
|
+
throw errorFactory?.(id) ?? new NotFoundError(`${this.name} ${String(id)} not found.`);
|
|
1641
1641
|
}
|
|
1642
1642
|
static async all(options = {}) {
|
|
1643
1643
|
const statics = modelStatics(this);
|
|
1644
|
-
const repository = resolveModelRepository(
|
|
1645
|
-
let query = Model.query.call(
|
|
1644
|
+
const repository = resolveModelRepository(this);
|
|
1645
|
+
let query = Model.query.call(this);
|
|
1646
1646
|
if (options.orderBy) {
|
|
1647
1647
|
query = query.orderBy(options.orderBy);
|
|
1648
1648
|
}
|
|
@@ -1654,8 +1654,8 @@ class Model {
|
|
|
1654
1654
|
}
|
|
1655
1655
|
static async firstWhere(where, options = {}) {
|
|
1656
1656
|
const statics = modelStatics(this);
|
|
1657
|
-
const repository = resolveModelRepository(
|
|
1658
|
-
let query = Model.query.call(
|
|
1657
|
+
const repository = resolveModelRepository(this);
|
|
1658
|
+
let query = Model.query.call(this).where(where);
|
|
1659
1659
|
if (options.orderBy) {
|
|
1660
1660
|
query = query.orderBy(options.orderBy);
|
|
1661
1661
|
}
|
package/dist/entries/http.js
CHANGED
|
@@ -1595,8 +1595,8 @@ class Model {
|
|
|
1595
1595
|
static boot() {}
|
|
1596
1596
|
static addGlobalScope(_name, scope) {
|
|
1597
1597
|
ensureBooted(this);
|
|
1598
|
-
const existing = modelGlobalScopes.get(
|
|
1599
|
-
modelGlobalScopes.set(
|
|
1598
|
+
const existing = modelGlobalScopes.get(this) ?? [];
|
|
1599
|
+
modelGlobalScopes.set(this, [
|
|
1600
1600
|
...existing,
|
|
1601
1601
|
scope
|
|
1602
1602
|
]);
|
|
@@ -1606,17 +1606,17 @@ class Model {
|
|
|
1606
1606
|
}
|
|
1607
1607
|
static query() {
|
|
1608
1608
|
ensureBooted(this);
|
|
1609
|
-
const repository = resolveModelRepository(
|
|
1609
|
+
const repository = resolveModelRepository(this);
|
|
1610
1610
|
let query = repository.query();
|
|
1611
|
-
for (const scope of getGlobalScopes(
|
|
1611
|
+
for (const scope of getGlobalScopes(this)) {
|
|
1612
1612
|
query = scope(query);
|
|
1613
1613
|
}
|
|
1614
1614
|
return query;
|
|
1615
1615
|
}
|
|
1616
1616
|
static async create(attributes) {
|
|
1617
1617
|
const statics = modelStatics(this);
|
|
1618
|
-
ensureBooted(
|
|
1619
|
-
const repository = resolveModelRepository(
|
|
1618
|
+
ensureBooted(this);
|
|
1619
|
+
const repository = resolveModelRepository(this);
|
|
1620
1620
|
const table = repository.getTable();
|
|
1621
1621
|
const timestamps = statics.$timestamps ?? true;
|
|
1622
1622
|
const assignable = filterMassAssignable(statics.$fillable, statics.$guarded, attributes);
|
|
@@ -1627,22 +1627,22 @@ class Model {
|
|
|
1627
1627
|
}
|
|
1628
1628
|
static async find(id) {
|
|
1629
1629
|
const statics = modelStatics(this);
|
|
1630
|
-
const repository = resolveModelRepository(
|
|
1630
|
+
const repository = resolveModelRepository(this);
|
|
1631
1631
|
const primaryKey = repository.getTable().primaryKey;
|
|
1632
|
-
const record = await Model.query.call(
|
|
1632
|
+
const record = await Model.query.call(this).where({ [primaryKey]: id }).first();
|
|
1633
1633
|
return record ? statics.fromRecord(record, repository, true) : null;
|
|
1634
1634
|
}
|
|
1635
1635
|
static async findOrFail(id, errorFactory) {
|
|
1636
|
-
const model = await Model.find.call(
|
|
1636
|
+
const model = await Model.find.call(this, id);
|
|
1637
1637
|
if (model) {
|
|
1638
1638
|
return model;
|
|
1639
1639
|
}
|
|
1640
|
-
throw errorFactory?.(id) ?? new NotFoundError(`${
|
|
1640
|
+
throw errorFactory?.(id) ?? new NotFoundError(`${this.name} ${String(id)} not found.`);
|
|
1641
1641
|
}
|
|
1642
1642
|
static async all(options = {}) {
|
|
1643
1643
|
const statics = modelStatics(this);
|
|
1644
|
-
const repository = resolveModelRepository(
|
|
1645
|
-
let query = Model.query.call(
|
|
1644
|
+
const repository = resolveModelRepository(this);
|
|
1645
|
+
let query = Model.query.call(this);
|
|
1646
1646
|
if (options.orderBy) {
|
|
1647
1647
|
query = query.orderBy(options.orderBy);
|
|
1648
1648
|
}
|
|
@@ -1654,8 +1654,8 @@ class Model {
|
|
|
1654
1654
|
}
|
|
1655
1655
|
static async firstWhere(where, options = {}) {
|
|
1656
1656
|
const statics = modelStatics(this);
|
|
1657
|
-
const repository = resolveModelRepository(
|
|
1658
|
-
let query = Model.query.call(
|
|
1657
|
+
const repository = resolveModelRepository(this);
|
|
1658
|
+
let query = Model.query.call(this).where(where);
|
|
1659
1659
|
if (options.orderBy) {
|
|
1660
1660
|
query = query.orderBy(options.orderBy);
|
|
1661
1661
|
}
|
|
@@ -1769,8 +1769,8 @@ class Model {
|
|
|
1769
1769
|
static boot() {}
|
|
1770
1770
|
static addGlobalScope(_name, scope) {
|
|
1771
1771
|
ensureBooted(this);
|
|
1772
|
-
const existing = modelGlobalScopes.get(
|
|
1773
|
-
modelGlobalScopes.set(
|
|
1772
|
+
const existing = modelGlobalScopes.get(this) ?? [];
|
|
1773
|
+
modelGlobalScopes.set(this, [
|
|
1774
1774
|
...existing,
|
|
1775
1775
|
scope
|
|
1776
1776
|
]);
|
|
@@ -1780,17 +1780,17 @@ class Model {
|
|
|
1780
1780
|
}
|
|
1781
1781
|
static query() {
|
|
1782
1782
|
ensureBooted(this);
|
|
1783
|
-
const repository = resolveModelRepository(
|
|
1783
|
+
const repository = resolveModelRepository(this);
|
|
1784
1784
|
let query = repository.query();
|
|
1785
|
-
for (const scope of getGlobalScopes(
|
|
1785
|
+
for (const scope of getGlobalScopes(this)) {
|
|
1786
1786
|
query = scope(query);
|
|
1787
1787
|
}
|
|
1788
1788
|
return query;
|
|
1789
1789
|
}
|
|
1790
1790
|
static async create(attributes) {
|
|
1791
1791
|
const statics = modelStatics(this);
|
|
1792
|
-
ensureBooted(
|
|
1793
|
-
const repository = resolveModelRepository(
|
|
1792
|
+
ensureBooted(this);
|
|
1793
|
+
const repository = resolveModelRepository(this);
|
|
1794
1794
|
const table = repository.getTable();
|
|
1795
1795
|
const timestamps = statics.$timestamps ?? true;
|
|
1796
1796
|
const assignable = filterMassAssignable(statics.$fillable, statics.$guarded, attributes);
|
|
@@ -1801,22 +1801,22 @@ class Model {
|
|
|
1801
1801
|
}
|
|
1802
1802
|
static async find(id) {
|
|
1803
1803
|
const statics = modelStatics(this);
|
|
1804
|
-
const repository = resolveModelRepository(
|
|
1804
|
+
const repository = resolveModelRepository(this);
|
|
1805
1805
|
const primaryKey = repository.getTable().primaryKey;
|
|
1806
|
-
const record = await Model.query.call(
|
|
1806
|
+
const record = await Model.query.call(this).where({ [primaryKey]: id }).first();
|
|
1807
1807
|
return record ? statics.fromRecord(record, repository, true) : null;
|
|
1808
1808
|
}
|
|
1809
1809
|
static async findOrFail(id, errorFactory) {
|
|
1810
|
-
const model = await Model.find.call(
|
|
1810
|
+
const model = await Model.find.call(this, id);
|
|
1811
1811
|
if (model) {
|
|
1812
1812
|
return model;
|
|
1813
1813
|
}
|
|
1814
|
-
throw errorFactory?.(id) ?? new NotFoundError(`${
|
|
1814
|
+
throw errorFactory?.(id) ?? new NotFoundError(`${this.name} ${String(id)} not found.`);
|
|
1815
1815
|
}
|
|
1816
1816
|
static async all(options = {}) {
|
|
1817
1817
|
const statics = modelStatics(this);
|
|
1818
|
-
const repository = resolveModelRepository(
|
|
1819
|
-
let query = Model.query.call(
|
|
1818
|
+
const repository = resolveModelRepository(this);
|
|
1819
|
+
let query = Model.query.call(this);
|
|
1820
1820
|
if (options.orderBy) {
|
|
1821
1821
|
query = query.orderBy(options.orderBy);
|
|
1822
1822
|
}
|
|
@@ -1828,8 +1828,8 @@ class Model {
|
|
|
1828
1828
|
}
|
|
1829
1829
|
static async firstWhere(where, options = {}) {
|
|
1830
1830
|
const statics = modelStatics(this);
|
|
1831
|
-
const repository = resolveModelRepository(
|
|
1832
|
-
let query = Model.query.call(
|
|
1831
|
+
const repository = resolveModelRepository(this);
|
|
1832
|
+
let query = Model.query.call(this).where(where);
|
|
1833
1833
|
if (options.orderBy) {
|
|
1834
1834
|
query = query.orderBy(options.orderBy);
|
|
1835
1835
|
}
|
|
@@ -1371,8 +1371,8 @@ class Model {
|
|
|
1371
1371
|
static boot() {}
|
|
1372
1372
|
static addGlobalScope(_name, scope) {
|
|
1373
1373
|
ensureBooted(this);
|
|
1374
|
-
const existing = modelGlobalScopes.get(
|
|
1375
|
-
modelGlobalScopes.set(
|
|
1374
|
+
const existing = modelGlobalScopes.get(this) ?? [];
|
|
1375
|
+
modelGlobalScopes.set(this, [
|
|
1376
1376
|
...existing,
|
|
1377
1377
|
scope
|
|
1378
1378
|
]);
|
|
@@ -1382,17 +1382,17 @@ class Model {
|
|
|
1382
1382
|
}
|
|
1383
1383
|
static query() {
|
|
1384
1384
|
ensureBooted(this);
|
|
1385
|
-
const repository = resolveModelRepository(
|
|
1385
|
+
const repository = resolveModelRepository(this);
|
|
1386
1386
|
let query = repository.query();
|
|
1387
|
-
for (const scope of getGlobalScopes(
|
|
1387
|
+
for (const scope of getGlobalScopes(this)) {
|
|
1388
1388
|
query = scope(query);
|
|
1389
1389
|
}
|
|
1390
1390
|
return query;
|
|
1391
1391
|
}
|
|
1392
1392
|
static async create(attributes) {
|
|
1393
1393
|
const statics = modelStatics(this);
|
|
1394
|
-
ensureBooted(
|
|
1395
|
-
const repository = resolveModelRepository(
|
|
1394
|
+
ensureBooted(this);
|
|
1395
|
+
const repository = resolveModelRepository(this);
|
|
1396
1396
|
const table = repository.getTable();
|
|
1397
1397
|
const timestamps = statics.$timestamps ?? true;
|
|
1398
1398
|
const assignable = filterMassAssignable(statics.$fillable, statics.$guarded, attributes);
|
|
@@ -1403,22 +1403,22 @@ class Model {
|
|
|
1403
1403
|
}
|
|
1404
1404
|
static async find(id) {
|
|
1405
1405
|
const statics = modelStatics(this);
|
|
1406
|
-
const repository = resolveModelRepository(
|
|
1406
|
+
const repository = resolveModelRepository(this);
|
|
1407
1407
|
const primaryKey = repository.getTable().primaryKey;
|
|
1408
|
-
const record = await Model.query.call(
|
|
1408
|
+
const record = await Model.query.call(this).where({ [primaryKey]: id }).first();
|
|
1409
1409
|
return record ? statics.fromRecord(record, repository, true) : null;
|
|
1410
1410
|
}
|
|
1411
1411
|
static async findOrFail(id, errorFactory) {
|
|
1412
|
-
const model = await Model.find.call(
|
|
1412
|
+
const model = await Model.find.call(this, id);
|
|
1413
1413
|
if (model) {
|
|
1414
1414
|
return model;
|
|
1415
1415
|
}
|
|
1416
|
-
throw errorFactory?.(id) ?? new NotFoundError(`${
|
|
1416
|
+
throw errorFactory?.(id) ?? new NotFoundError(`${this.name} ${String(id)} not found.`);
|
|
1417
1417
|
}
|
|
1418
1418
|
static async all(options = {}) {
|
|
1419
1419
|
const statics = modelStatics(this);
|
|
1420
|
-
const repository = resolveModelRepository(
|
|
1421
|
-
let query = Model.query.call(
|
|
1420
|
+
const repository = resolveModelRepository(this);
|
|
1421
|
+
let query = Model.query.call(this);
|
|
1422
1422
|
if (options.orderBy) {
|
|
1423
1423
|
query = query.orderBy(options.orderBy);
|
|
1424
1424
|
}
|
|
@@ -1430,8 +1430,8 @@ class Model {
|
|
|
1430
1430
|
}
|
|
1431
1431
|
static async firstWhere(where, options = {}) {
|
|
1432
1432
|
const statics = modelStatics(this);
|
|
1433
|
-
const repository = resolveModelRepository(
|
|
1434
|
-
let query = Model.query.call(
|
|
1433
|
+
const repository = resolveModelRepository(this);
|
|
1434
|
+
let query = Model.query.call(this).where(where);
|
|
1435
1435
|
if (options.orderBy) {
|
|
1436
1436
|
query = query.orderBy(options.orderBy);
|
|
1437
1437
|
}
|
|
@@ -1779,8 +1779,8 @@ class Model {
|
|
|
1779
1779
|
static boot() {}
|
|
1780
1780
|
static addGlobalScope(_name, scope) {
|
|
1781
1781
|
ensureBooted(this);
|
|
1782
|
-
const existing = modelGlobalScopes.get(
|
|
1783
|
-
modelGlobalScopes.set(
|
|
1782
|
+
const existing = modelGlobalScopes.get(this) ?? [];
|
|
1783
|
+
modelGlobalScopes.set(this, [
|
|
1784
1784
|
...existing,
|
|
1785
1785
|
scope
|
|
1786
1786
|
]);
|
|
@@ -1790,17 +1790,17 @@ class Model {
|
|
|
1790
1790
|
}
|
|
1791
1791
|
static query() {
|
|
1792
1792
|
ensureBooted(this);
|
|
1793
|
-
const repository = resolveModelRepository(
|
|
1793
|
+
const repository = resolveModelRepository(this);
|
|
1794
1794
|
let query = repository.query();
|
|
1795
|
-
for (const scope of getGlobalScopes(
|
|
1795
|
+
for (const scope of getGlobalScopes(this)) {
|
|
1796
1796
|
query = scope(query);
|
|
1797
1797
|
}
|
|
1798
1798
|
return query;
|
|
1799
1799
|
}
|
|
1800
1800
|
static async create(attributes) {
|
|
1801
1801
|
const statics = modelStatics(this);
|
|
1802
|
-
ensureBooted(
|
|
1803
|
-
const repository = resolveModelRepository(
|
|
1802
|
+
ensureBooted(this);
|
|
1803
|
+
const repository = resolveModelRepository(this);
|
|
1804
1804
|
const table = repository.getTable();
|
|
1805
1805
|
const timestamps = statics.$timestamps ?? true;
|
|
1806
1806
|
const assignable = filterMassAssignable(statics.$fillable, statics.$guarded, attributes);
|
|
@@ -1811,22 +1811,22 @@ class Model {
|
|
|
1811
1811
|
}
|
|
1812
1812
|
static async find(id) {
|
|
1813
1813
|
const statics = modelStatics(this);
|
|
1814
|
-
const repository = resolveModelRepository(
|
|
1814
|
+
const repository = resolveModelRepository(this);
|
|
1815
1815
|
const primaryKey = repository.getTable().primaryKey;
|
|
1816
|
-
const record = await Model.query.call(
|
|
1816
|
+
const record = await Model.query.call(this).where({ [primaryKey]: id }).first();
|
|
1817
1817
|
return record ? statics.fromRecord(record, repository, true) : null;
|
|
1818
1818
|
}
|
|
1819
1819
|
static async findOrFail(id, errorFactory) {
|
|
1820
|
-
const model = await Model.find.call(
|
|
1820
|
+
const model = await Model.find.call(this, id);
|
|
1821
1821
|
if (model) {
|
|
1822
1822
|
return model;
|
|
1823
1823
|
}
|
|
1824
|
-
throw errorFactory?.(id) ?? new NotFoundError(`${
|
|
1824
|
+
throw errorFactory?.(id) ?? new NotFoundError(`${this.name} ${String(id)} not found.`);
|
|
1825
1825
|
}
|
|
1826
1826
|
static async all(options = {}) {
|
|
1827
1827
|
const statics = modelStatics(this);
|
|
1828
|
-
const repository = resolveModelRepository(
|
|
1829
|
-
let query = Model.query.call(
|
|
1828
|
+
const repository = resolveModelRepository(this);
|
|
1829
|
+
let query = Model.query.call(this);
|
|
1830
1830
|
if (options.orderBy) {
|
|
1831
1831
|
query = query.orderBy(options.orderBy);
|
|
1832
1832
|
}
|
|
@@ -1838,8 +1838,8 @@ class Model {
|
|
|
1838
1838
|
}
|
|
1839
1839
|
static async firstWhere(where, options = {}) {
|
|
1840
1840
|
const statics = modelStatics(this);
|
|
1841
|
-
const repository = resolveModelRepository(
|
|
1842
|
-
let query = Model.query.call(
|
|
1841
|
+
const repository = resolveModelRepository(this);
|
|
1842
|
+
let query = Model.query.call(this).where(where);
|
|
1843
1843
|
if (options.orderBy) {
|
|
1844
1844
|
query = query.orderBy(options.orderBy);
|
|
1845
1845
|
}
|
package/dist/entries/view.js
CHANGED
|
@@ -1580,8 +1580,8 @@ class Model {
|
|
|
1580
1580
|
static boot() {}
|
|
1581
1581
|
static addGlobalScope(_name, scope) {
|
|
1582
1582
|
ensureBooted(this);
|
|
1583
|
-
const existing = modelGlobalScopes.get(
|
|
1584
|
-
modelGlobalScopes.set(
|
|
1583
|
+
const existing = modelGlobalScopes.get(this) ?? [];
|
|
1584
|
+
modelGlobalScopes.set(this, [
|
|
1585
1585
|
...existing,
|
|
1586
1586
|
scope
|
|
1587
1587
|
]);
|
|
@@ -1591,17 +1591,17 @@ class Model {
|
|
|
1591
1591
|
}
|
|
1592
1592
|
static query() {
|
|
1593
1593
|
ensureBooted(this);
|
|
1594
|
-
const repository = resolveModelRepository(
|
|
1594
|
+
const repository = resolveModelRepository(this);
|
|
1595
1595
|
let query = repository.query();
|
|
1596
|
-
for (const scope of getGlobalScopes(
|
|
1596
|
+
for (const scope of getGlobalScopes(this)) {
|
|
1597
1597
|
query = scope(query);
|
|
1598
1598
|
}
|
|
1599
1599
|
return query;
|
|
1600
1600
|
}
|
|
1601
1601
|
static async create(attributes) {
|
|
1602
1602
|
const statics = modelStatics(this);
|
|
1603
|
-
ensureBooted(
|
|
1604
|
-
const repository = resolveModelRepository(
|
|
1603
|
+
ensureBooted(this);
|
|
1604
|
+
const repository = resolveModelRepository(this);
|
|
1605
1605
|
const table = repository.getTable();
|
|
1606
1606
|
const timestamps = statics.$timestamps ?? true;
|
|
1607
1607
|
const assignable = filterMassAssignable(statics.$fillable, statics.$guarded, attributes);
|
|
@@ -1612,22 +1612,22 @@ class Model {
|
|
|
1612
1612
|
}
|
|
1613
1613
|
static async find(id) {
|
|
1614
1614
|
const statics = modelStatics(this);
|
|
1615
|
-
const repository = resolveModelRepository(
|
|
1615
|
+
const repository = resolveModelRepository(this);
|
|
1616
1616
|
const primaryKey = repository.getTable().primaryKey;
|
|
1617
|
-
const record = await Model.query.call(
|
|
1617
|
+
const record = await Model.query.call(this).where({ [primaryKey]: id }).first();
|
|
1618
1618
|
return record ? statics.fromRecord(record, repository, true) : null;
|
|
1619
1619
|
}
|
|
1620
1620
|
static async findOrFail(id, errorFactory) {
|
|
1621
|
-
const model = await Model.find.call(
|
|
1621
|
+
const model = await Model.find.call(this, id);
|
|
1622
1622
|
if (model) {
|
|
1623
1623
|
return model;
|
|
1624
1624
|
}
|
|
1625
|
-
throw errorFactory?.(id) ?? new NotFoundError(`${
|
|
1625
|
+
throw errorFactory?.(id) ?? new NotFoundError(`${this.name} ${String(id)} not found.`);
|
|
1626
1626
|
}
|
|
1627
1627
|
static async all(options = {}) {
|
|
1628
1628
|
const statics = modelStatics(this);
|
|
1629
|
-
const repository = resolveModelRepository(
|
|
1630
|
-
let query = Model.query.call(
|
|
1629
|
+
const repository = resolveModelRepository(this);
|
|
1630
|
+
let query = Model.query.call(this);
|
|
1631
1631
|
if (options.orderBy) {
|
|
1632
1632
|
query = query.orderBy(options.orderBy);
|
|
1633
1633
|
}
|
|
@@ -1639,8 +1639,8 @@ class Model {
|
|
|
1639
1639
|
}
|
|
1640
1640
|
static async firstWhere(where, options = {}) {
|
|
1641
1641
|
const statics = modelStatics(this);
|
|
1642
|
-
const repository = resolveModelRepository(
|
|
1643
|
-
let query = Model.query.call(
|
|
1642
|
+
const repository = resolveModelRepository(this);
|
|
1643
|
+
let query = Model.query.call(this).where(where);
|
|
1644
1644
|
if (options.orderBy) {
|
|
1645
1645
|
query = query.orderBy(options.orderBy);
|
|
1646
1646
|
}
|
package/dist/index.js
CHANGED
|
@@ -1765,8 +1765,8 @@ class Model {
|
|
|
1765
1765
|
static boot() {}
|
|
1766
1766
|
static addGlobalScope(_name, scope) {
|
|
1767
1767
|
ensureBooted(this);
|
|
1768
|
-
const existing = modelGlobalScopes.get(
|
|
1769
|
-
modelGlobalScopes.set(
|
|
1768
|
+
const existing = modelGlobalScopes.get(this) ?? [];
|
|
1769
|
+
modelGlobalScopes.set(this, [
|
|
1770
1770
|
...existing,
|
|
1771
1771
|
scope
|
|
1772
1772
|
]);
|
|
@@ -1776,17 +1776,17 @@ class Model {
|
|
|
1776
1776
|
}
|
|
1777
1777
|
static query() {
|
|
1778
1778
|
ensureBooted(this);
|
|
1779
|
-
const repository = resolveModelRepository(
|
|
1779
|
+
const repository = resolveModelRepository(this);
|
|
1780
1780
|
let query = repository.query();
|
|
1781
|
-
for (const scope of getGlobalScopes(
|
|
1781
|
+
for (const scope of getGlobalScopes(this)) {
|
|
1782
1782
|
query = scope(query);
|
|
1783
1783
|
}
|
|
1784
1784
|
return query;
|
|
1785
1785
|
}
|
|
1786
1786
|
static async create(attributes) {
|
|
1787
1787
|
const statics = modelStatics(this);
|
|
1788
|
-
ensureBooted(
|
|
1789
|
-
const repository = resolveModelRepository(
|
|
1788
|
+
ensureBooted(this);
|
|
1789
|
+
const repository = resolveModelRepository(this);
|
|
1790
1790
|
const table = repository.getTable();
|
|
1791
1791
|
const timestamps = statics.$timestamps ?? true;
|
|
1792
1792
|
const assignable = filterMassAssignable(statics.$fillable, statics.$guarded, attributes);
|
|
@@ -1797,22 +1797,22 @@ class Model {
|
|
|
1797
1797
|
}
|
|
1798
1798
|
static async find(id) {
|
|
1799
1799
|
const statics = modelStatics(this);
|
|
1800
|
-
const repository = resolveModelRepository(
|
|
1800
|
+
const repository = resolveModelRepository(this);
|
|
1801
1801
|
const primaryKey = repository.getTable().primaryKey;
|
|
1802
|
-
const record = await Model.query.call(
|
|
1802
|
+
const record = await Model.query.call(this).where({ [primaryKey]: id }).first();
|
|
1803
1803
|
return record ? statics.fromRecord(record, repository, true) : null;
|
|
1804
1804
|
}
|
|
1805
1805
|
static async findOrFail(id, errorFactory) {
|
|
1806
|
-
const model = await Model.find.call(
|
|
1806
|
+
const model = await Model.find.call(this, id);
|
|
1807
1807
|
if (model) {
|
|
1808
1808
|
return model;
|
|
1809
1809
|
}
|
|
1810
|
-
throw errorFactory?.(id) ?? new NotFoundError(`${
|
|
1810
|
+
throw errorFactory?.(id) ?? new NotFoundError(`${this.name} ${String(id)} not found.`);
|
|
1811
1811
|
}
|
|
1812
1812
|
static async all(options = {}) {
|
|
1813
1813
|
const statics = modelStatics(this);
|
|
1814
|
-
const repository = resolveModelRepository(
|
|
1815
|
-
let query = Model.query.call(
|
|
1814
|
+
const repository = resolveModelRepository(this);
|
|
1815
|
+
let query = Model.query.call(this);
|
|
1816
1816
|
if (options.orderBy) {
|
|
1817
1817
|
query = query.orderBy(options.orderBy);
|
|
1818
1818
|
}
|
|
@@ -1824,8 +1824,8 @@ class Model {
|
|
|
1824
1824
|
}
|
|
1825
1825
|
static async firstWhere(where, options = {}) {
|
|
1826
1826
|
const statics = modelStatics(this);
|
|
1827
|
-
const repository = resolveModelRepository(
|
|
1828
|
-
let query = Model.query.call(
|
|
1827
|
+
const repository = resolveModelRepository(this);
|
|
1828
|
+
let query = Model.query.call(this).where(where);
|
|
1829
1829
|
if (options.orderBy) {
|
|
1830
1830
|
query = query.orderBy(options.orderBy);
|
|
1831
1831
|
}
|