@warlock.js/cascade 1.0.3 → 1.0.4

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.
Files changed (43) hide show
  1. package/cjs/index.d.ts +0 -1
  2. package/cjs/index.d.ts.map +1 -1
  3. package/cjs/index.js +1 -1
  4. package/esm/index.d.ts +0 -1
  5. package/esm/index.d.ts.map +1 -1
  6. package/esm/index.js +1 -1
  7. package/package.json +2 -1
  8. package/cjs/console/db-indexes-command.d.ts +0 -3
  9. package/cjs/console/db-indexes-command.d.ts.map +0 -1
  10. package/cjs/console/db-indexes-command.js +0 -18
  11. package/cjs/console/db-indexes-command.js.map +0 -1
  12. package/cjs/console/index.d.ts +0 -4
  13. package/cjs/console/index.d.ts.map +0 -1
  14. package/cjs/console/migrate-command.d.ts +0 -2
  15. package/cjs/console/migrate-command.d.ts.map +0 -1
  16. package/cjs/console/migrate-command.js +0 -13
  17. package/cjs/console/migrate-command.js.map +0 -1
  18. package/cjs/console/register-blueprint-command.d.ts +0 -2
  19. package/cjs/console/register-blueprint-command.d.ts.map +0 -1
  20. package/cjs/console/register-blueprint-command.js +0 -19
  21. package/cjs/console/register-blueprint-command.js.map +0 -1
  22. package/cjs/model/relationships.d.ts +0 -69
  23. package/cjs/model/relationships.d.ts.map +0 -1
  24. package/cjs/model/relationships.js +0 -144
  25. package/cjs/model/relationships.js.map +0 -1
  26. package/esm/console/db-indexes-command.d.ts +0 -3
  27. package/esm/console/db-indexes-command.d.ts.map +0 -1
  28. package/esm/console/db-indexes-command.js +0 -18
  29. package/esm/console/db-indexes-command.js.map +0 -1
  30. package/esm/console/index.d.ts +0 -4
  31. package/esm/console/index.d.ts.map +0 -1
  32. package/esm/console/migrate-command.d.ts +0 -2
  33. package/esm/console/migrate-command.d.ts.map +0 -1
  34. package/esm/console/migrate-command.js +0 -13
  35. package/esm/console/migrate-command.js.map +0 -1
  36. package/esm/console/register-blueprint-command.d.ts +0 -2
  37. package/esm/console/register-blueprint-command.d.ts.map +0 -1
  38. package/esm/console/register-blueprint-command.js +0 -19
  39. package/esm/console/register-blueprint-command.js.map +0 -1
  40. package/esm/model/relationships.d.ts +0 -69
  41. package/esm/model/relationships.d.ts.map +0 -1
  42. package/esm/model/relationships.js +0 -144
  43. package/esm/model/relationships.js.map +0 -1
package/cjs/index.d.ts CHANGED
@@ -3,7 +3,6 @@ export * from "./blueprint";
3
3
  export * from "./casts";
4
4
  export * from "./config";
5
5
  export * from "./connection";
6
- export * from "./console";
7
6
  export * from "./database";
8
7
  export * from "./migration";
9
8
  export * from "./model";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/cjs/index.js CHANGED
@@ -1 +1 @@
1
- 'use strict';var DeselectPipeline=require('./aggregate/DeselectPipeline.js'),GeoNearPipeline=require('./aggregate/GeoNearPipeline.js'),GroupByPipeline=require('./aggregate/GroupByPipeline.js'),LimitPipeline=require('./aggregate/LimitPipeline.js'),LookupPipeline=require('./aggregate/LookupPipeline.js'),OrWherePipeline=require('./aggregate/OrWherePipeline.js'),SelectPipeline=require('./aggregate/SelectPipeline.js'),SkipPipeline=require('./aggregate/SkipPipeline.js'),SortByPipeline=require('./aggregate/SortByPipeline.js'),SortPipeline=require('./aggregate/SortPipeline.js'),SortRandomPipeline=require('./aggregate/SortRandomPipeline.js'),UnwindPipeline=require('./aggregate/UnwindPipeline.js'),WhereExpression=require('./aggregate/WhereExpression.js'),WhereExpressionPipeline=require('./aggregate/WhereExpressionPipeline.js'),WherePipeline=require('./aggregate/WherePipeline.js'),aggregate=require('./aggregate/aggregate.js'),expressions=require('./aggregate/expressions.js'),parsePipelines=require('./aggregate/parsePipelines.js'),pipeline=require('./aggregate/pipeline.js'),types=require('./aggregate/types.js'),blueprint=require('./blueprint/blueprint.js'),modelBlueprint=require('./blueprint/model-blueprint.js'),arrayOf=require('./casts/arrayOf.js'),castEmail=require('./casts/cast-email.js'),castModel=require('./casts/castModel.js'),expiresAfter=require('./casts/expiresAfter.js'),oneOf=require('./casts/oneOf.js'),randomString=require('./casts/random-string.js'),randomInteger=require('./casts/randomInteger.js'),shapedArray=require('./casts/shapedArray.js'),config=require('./config.js'),connection=require('./connection.js'),dbIndexesCommand=require('./console/db-indexes-command.js'),migrateCommand=require('./console/migrate-command.js'),registerBlueprintCommand=require('./console/register-blueprint-command.js'),database=require('./database.js'),migrate=require('./migration/migrate.js'),migrationOffice=require('./migration/migration-office.js'),ModelAggregate=require('./model/ModelAggregate.js'),ModelSync=require('./model/ModelSync.js'),baseModel=require('./model/base-model.js'),crudModel=require('./model/crud-model.js'),joinable=require('./model/joinable.js'),masterMind=require('./model/master-mind.js'),model=require('./model/model.js'),types$1=require('./model/types.js'),query=require('./query/query.js'),connectToDatabase=require('./utils/connectToDatabase.js'),dropAllDatabaseIndexes=require('./utils/dropAllDatabaseIndexes.js'),listDatabaseIndexes=require('./utils/listDatabaseIndexes.js'),onceConnected=require('./utils/onceConnected.js');exports.DeselectPipeline=DeselectPipeline.DeselectPipeline;exports.deselectPipeline=DeselectPipeline.deselectPipeline;exports.GeoNearPipeline=GeoNearPipeline.GeoNearPipeline;exports.geoNearPipeline=GeoNearPipeline.geoNearPipeline;exports.GroupByPipeline=GroupByPipeline.GroupByPipeline;exports.groupByPipeline=GroupByPipeline.groupByPipeline;exports.LimitPipeline=LimitPipeline.LimitPipeline;exports.limitPipeline=LimitPipeline.limitPipeline;exports.LookupPipeline=LookupPipeline.LookupPipeline;exports.lookupPipeline=LookupPipeline.lookupPipeline;exports.OrWherePipeline=OrWherePipeline.OrWherePipeline;exports.orWherePipeline=OrWherePipeline.orWherePipeline;exports.SelectPipeline=SelectPipeline.SelectPipeline;exports.selectPipeline=SelectPipeline.selectPipeline;exports.SkipPipeline=SkipPipeline.SkipPipeline;exports.skipPipeline=SkipPipeline.skipPipeline;exports.SortByPipeline=SortByPipeline.SortByPipeline;exports.sortByPipeline=SortByPipeline.sortByPipeline;exports.SortPipeline=SortPipeline.SortPipeline;exports.sortPipeline=SortPipeline.sortPipeline;exports.SortRandomPipeline=SortRandomPipeline.SortRandomPipeline;exports.sortRandomPipeline=SortRandomPipeline.sortRandomPipeline;exports.UnwindPipeline=UnwindPipeline.UnwindPipeline;exports.unwindPipeline=UnwindPipeline.unwindPipeline;exports.WhereExpression=WhereExpression.WhereExpression;exports.parseValuesInObject=WhereExpression.parseValuesInObject;exports.toOperator=WhereExpression.toOperator;exports.WhereExpressionPipeline=WhereExpressionPipeline.WhereExpressionPipeline;exports.WherePipeline=WherePipeline.WherePipeline;exports.wherePipeline=WherePipeline.wherePipeline;exports.Aggregate=aggregate.Aggregate;exports.$agg=expressions.$agg;exports._divide=expressions._divide;exports._multiply=expressions._multiply;exports._round=expressions._round;exports.addToSet=expressions.addToSet;exports.all=expressions.all;exports.average=expressions.average;exports.avg=expressions.avg;exports.between=expressions.between;exports.booleanCond=expressions.booleanCond;exports.columnName=expressions.columnName;exports.columns=expressions.columns;exports.concat=expressions.concat;exports.concatWith=expressions.concatWith;exports.cond=expressions.cond;exports.condition=expressions.condition;exports.count=expressions.count;exports.dayOfMonth=expressions.dayOfMonth;exports.dayOfWeek=expressions.dayOfWeek;exports.divide=expressions.divide;exports.eq=expressions.eq;exports.equal=expressions.equal;exports.exists=expressions.exists;exports.expr=expressions.expr;exports.first=expressions.first;exports.firstDayOfMonth=expressions.firstDayOfMonth;exports.firstMonth=expressions.firstMonth;exports.firstYear=expressions.firstYear;exports.greaterThan=expressions.greaterThan;exports.greaterThanOrEqual=expressions.greaterThanOrEqual;exports.gt=expressions.gt;exports.gte=expressions.gte;exports.inArray=expressions.inArray;exports.isNull=expressions.isNull;exports.last=expressions.last;exports.lastDayOfMonth=expressions.lastDayOfMonth;exports.lastMonth=expressions.lastMonth;exports.lastYear=expressions.lastYear;exports.lessThan=expressions.lessThan;exports.lessThanOrEqual=expressions.lessThanOrEqual;exports.like=expressions.like;exports.lt=expressions.lt;exports.lte=expressions.lte;exports.max=expressions.max;exports.merge=expressions.merge;exports.mergeWith=expressions.mergeWith;exports.min=expressions.min;exports.month=expressions.month;exports.multiply=expressions.multiply;exports.ne=expressions.ne;exports.nin=expressions.nin;exports.notBetween=expressions.notBetween;exports.notEqual=expressions.notEqual;exports.notExists=expressions.notExists;exports.notIn=expressions.notIn;exports.notInArray=expressions.notInArray;exports.notLike=expressions.notLike;exports.notNull=expressions.notNull;exports.push=expressions.push;exports.regex=expressions.regex;exports.round=expressions.round;exports.size=expressions.size;exports.sum=expressions.sum;exports.week=expressions.week;exports.year=expressions.year;exports.parsePipeline=parsePipelines.parsePipeline;exports.parsePipelines=parsePipelines.parsePipelines;exports.Pipeline=pipeline.Pipeline;exports.whereOperators=types.whereOperators;exports.Blueprint=blueprint.Blueprint;exports.blueprint=blueprint.blueprint;exports.ModelBlueprint=modelBlueprint.ModelBlueprint;exports.modelBlueprint=modelBlueprint.modelBlueprint;exports.arrayOf=arrayOf.arrayOf;exports.castEmail=castEmail.castEmail;exports.castModel=castModel.castModel;exports.expiresAfter=expiresAfter.expiresAfter;exports.castEnum=oneOf.castEnum;exports.oneOf=oneOf.oneOf;exports.randomString=randomString.randomString;exports.randomInteger=randomInteger.randomInteger;Object.defineProperty(exports,'ShapedArrayType',{enumerable:true,get:function(){return shapedArray.ShapedArrayType}});exports.shapedArray=shapedArray.shapedArray;exports.getDatabaseConfigurations=config.getDatabaseConfigurations;exports.setDatabaseConfigurations=config.setDatabaseConfigurations;exports.Connection=connection.Connection;exports.connection=connection.connection;exports.registerDatabaseIndexesCommand=dbIndexesCommand.registerDatabaseIndexesCommand;exports.registerMigrationCommand=migrateCommand.registerMigrationCommand;exports.parseBlueprint=registerBlueprintCommand.parseBlueprint;exports.Database=database.Database;exports.database=database.database;exports.dropMigrations=migrate.dropMigrations;exports.listMigrations=migrate.listMigrations;exports.migrate=migrate.migrate;exports.MigrationOffice=migrationOffice.MigrationOffice;exports.migrationOffice=migrationOffice.migrationOffice;exports.ModelAggregate=ModelAggregate.ModelAggregate;exports.ModelSync=ModelSync.ModelSync;exports.BaseModel=baseModel.BaseModel;exports.CrudModel=crudModel.CrudModel;exports.Joinable=joinable.Joinable;exports.MasterMind=masterMind.MasterMind;exports.masterMind=masterMind.masterMind;exports.Model=model.Model;Object.defineProperty(exports,'ModelDeleteStrategy',{enumerable:true,get:function(){return types$1.ModelDeleteStrategy}});exports.Query=query.Query;exports.query=query.query;exports.connectToDatabase=connectToDatabase.connectToDatabase;exports.dropAllDatabaseIndexes=dropAllDatabaseIndexes.dropAllDatabaseIndexes;exports.listDatabaseIndexes=listDatabaseIndexes.listDatabaseIndexes;exports.listIndexesForCertainCollections=listDatabaseIndexes.listIndexesForCertainCollections;exports.printCollectionIndexes=listDatabaseIndexes.printCollectionIndexes;exports.onceConnected=onceConnected.onceConnected;//# sourceMappingURL=index.js.map
1
+ 'use strict';var DeselectPipeline=require('./aggregate/DeselectPipeline.js'),GeoNearPipeline=require('./aggregate/GeoNearPipeline.js'),GroupByPipeline=require('./aggregate/GroupByPipeline.js'),LimitPipeline=require('./aggregate/LimitPipeline.js'),LookupPipeline=require('./aggregate/LookupPipeline.js'),OrWherePipeline=require('./aggregate/OrWherePipeline.js'),SelectPipeline=require('./aggregate/SelectPipeline.js'),SkipPipeline=require('./aggregate/SkipPipeline.js'),SortByPipeline=require('./aggregate/SortByPipeline.js'),SortPipeline=require('./aggregate/SortPipeline.js'),SortRandomPipeline=require('./aggregate/SortRandomPipeline.js'),UnwindPipeline=require('./aggregate/UnwindPipeline.js'),WhereExpression=require('./aggregate/WhereExpression.js'),WhereExpressionPipeline=require('./aggregate/WhereExpressionPipeline.js'),WherePipeline=require('./aggregate/WherePipeline.js'),aggregate=require('./aggregate/aggregate.js'),expressions=require('./aggregate/expressions.js'),parsePipelines=require('./aggregate/parsePipelines.js'),pipeline=require('./aggregate/pipeline.js'),types=require('./aggregate/types.js'),blueprint=require('./blueprint/blueprint.js'),modelBlueprint=require('./blueprint/model-blueprint.js'),arrayOf=require('./casts/arrayOf.js'),castEmail=require('./casts/cast-email.js'),castModel=require('./casts/castModel.js'),expiresAfter=require('./casts/expiresAfter.js'),oneOf=require('./casts/oneOf.js'),randomString=require('./casts/random-string.js'),randomInteger=require('./casts/randomInteger.js'),shapedArray=require('./casts/shapedArray.js'),config=require('./config.js'),connection=require('./connection.js'),database=require('./database.js'),migrate=require('./migration/migrate.js'),migrationOffice=require('./migration/migration-office.js'),ModelAggregate=require('./model/ModelAggregate.js'),ModelSync=require('./model/ModelSync.js'),baseModel=require('./model/base-model.js'),crudModel=require('./model/crud-model.js'),joinable=require('./model/joinable.js'),masterMind=require('./model/master-mind.js'),model=require('./model/model.js'),types$1=require('./model/types.js'),query=require('./query/query.js'),connectToDatabase=require('./utils/connectToDatabase.js'),dropAllDatabaseIndexes=require('./utils/dropAllDatabaseIndexes.js'),listDatabaseIndexes=require('./utils/listDatabaseIndexes.js'),onceConnected=require('./utils/onceConnected.js');exports.DeselectPipeline=DeselectPipeline.DeselectPipeline;exports.deselectPipeline=DeselectPipeline.deselectPipeline;exports.GeoNearPipeline=GeoNearPipeline.GeoNearPipeline;exports.geoNearPipeline=GeoNearPipeline.geoNearPipeline;exports.GroupByPipeline=GroupByPipeline.GroupByPipeline;exports.groupByPipeline=GroupByPipeline.groupByPipeline;exports.LimitPipeline=LimitPipeline.LimitPipeline;exports.limitPipeline=LimitPipeline.limitPipeline;exports.LookupPipeline=LookupPipeline.LookupPipeline;exports.lookupPipeline=LookupPipeline.lookupPipeline;exports.OrWherePipeline=OrWherePipeline.OrWherePipeline;exports.orWherePipeline=OrWherePipeline.orWherePipeline;exports.SelectPipeline=SelectPipeline.SelectPipeline;exports.selectPipeline=SelectPipeline.selectPipeline;exports.SkipPipeline=SkipPipeline.SkipPipeline;exports.skipPipeline=SkipPipeline.skipPipeline;exports.SortByPipeline=SortByPipeline.SortByPipeline;exports.sortByPipeline=SortByPipeline.sortByPipeline;exports.SortPipeline=SortPipeline.SortPipeline;exports.sortPipeline=SortPipeline.sortPipeline;exports.SortRandomPipeline=SortRandomPipeline.SortRandomPipeline;exports.sortRandomPipeline=SortRandomPipeline.sortRandomPipeline;exports.UnwindPipeline=UnwindPipeline.UnwindPipeline;exports.unwindPipeline=UnwindPipeline.unwindPipeline;exports.WhereExpression=WhereExpression.WhereExpression;exports.parseValuesInObject=WhereExpression.parseValuesInObject;exports.toOperator=WhereExpression.toOperator;exports.WhereExpressionPipeline=WhereExpressionPipeline.WhereExpressionPipeline;exports.WherePipeline=WherePipeline.WherePipeline;exports.wherePipeline=WherePipeline.wherePipeline;exports.Aggregate=aggregate.Aggregate;exports.$agg=expressions.$agg;exports._divide=expressions._divide;exports._multiply=expressions._multiply;exports._round=expressions._round;exports.addToSet=expressions.addToSet;exports.all=expressions.all;exports.average=expressions.average;exports.avg=expressions.avg;exports.between=expressions.between;exports.booleanCond=expressions.booleanCond;exports.columnName=expressions.columnName;exports.columns=expressions.columns;exports.concat=expressions.concat;exports.concatWith=expressions.concatWith;exports.cond=expressions.cond;exports.condition=expressions.condition;exports.count=expressions.count;exports.dayOfMonth=expressions.dayOfMonth;exports.dayOfWeek=expressions.dayOfWeek;exports.divide=expressions.divide;exports.eq=expressions.eq;exports.equal=expressions.equal;exports.exists=expressions.exists;exports.expr=expressions.expr;exports.first=expressions.first;exports.firstDayOfMonth=expressions.firstDayOfMonth;exports.firstMonth=expressions.firstMonth;exports.firstYear=expressions.firstYear;exports.greaterThan=expressions.greaterThan;exports.greaterThanOrEqual=expressions.greaterThanOrEqual;exports.gt=expressions.gt;exports.gte=expressions.gte;exports.inArray=expressions.inArray;exports.isNull=expressions.isNull;exports.last=expressions.last;exports.lastDayOfMonth=expressions.lastDayOfMonth;exports.lastMonth=expressions.lastMonth;exports.lastYear=expressions.lastYear;exports.lessThan=expressions.lessThan;exports.lessThanOrEqual=expressions.lessThanOrEqual;exports.like=expressions.like;exports.lt=expressions.lt;exports.lte=expressions.lte;exports.max=expressions.max;exports.merge=expressions.merge;exports.mergeWith=expressions.mergeWith;exports.min=expressions.min;exports.month=expressions.month;exports.multiply=expressions.multiply;exports.ne=expressions.ne;exports.nin=expressions.nin;exports.notBetween=expressions.notBetween;exports.notEqual=expressions.notEqual;exports.notExists=expressions.notExists;exports.notIn=expressions.notIn;exports.notInArray=expressions.notInArray;exports.notLike=expressions.notLike;exports.notNull=expressions.notNull;exports.push=expressions.push;exports.regex=expressions.regex;exports.round=expressions.round;exports.size=expressions.size;exports.sum=expressions.sum;exports.week=expressions.week;exports.year=expressions.year;exports.parsePipeline=parsePipelines.parsePipeline;exports.parsePipelines=parsePipelines.parsePipelines;exports.Pipeline=pipeline.Pipeline;exports.whereOperators=types.whereOperators;exports.Blueprint=blueprint.Blueprint;exports.blueprint=blueprint.blueprint;exports.ModelBlueprint=modelBlueprint.ModelBlueprint;exports.modelBlueprint=modelBlueprint.modelBlueprint;exports.arrayOf=arrayOf.arrayOf;exports.castEmail=castEmail.castEmail;exports.castModel=castModel.castModel;exports.expiresAfter=expiresAfter.expiresAfter;exports.castEnum=oneOf.castEnum;exports.oneOf=oneOf.oneOf;exports.randomString=randomString.randomString;exports.randomInteger=randomInteger.randomInteger;Object.defineProperty(exports,'ShapedArrayType',{enumerable:true,get:function(){return shapedArray.ShapedArrayType}});exports.shapedArray=shapedArray.shapedArray;exports.getDatabaseConfigurations=config.getDatabaseConfigurations;exports.setDatabaseConfigurations=config.setDatabaseConfigurations;exports.Connection=connection.Connection;exports.connection=connection.connection;exports.Database=database.Database;exports.database=database.database;exports.dropMigrations=migrate.dropMigrations;exports.listMigrations=migrate.listMigrations;exports.migrate=migrate.migrate;exports.MigrationOffice=migrationOffice.MigrationOffice;exports.migrationOffice=migrationOffice.migrationOffice;exports.ModelAggregate=ModelAggregate.ModelAggregate;exports.ModelSync=ModelSync.ModelSync;exports.BaseModel=baseModel.BaseModel;exports.CrudModel=crudModel.CrudModel;exports.Joinable=joinable.Joinable;exports.MasterMind=masterMind.MasterMind;exports.masterMind=masterMind.masterMind;exports.Model=model.Model;Object.defineProperty(exports,'ModelDeleteStrategy',{enumerable:true,get:function(){return types$1.ModelDeleteStrategy}});exports.Query=query.Query;exports.query=query.query;exports.connectToDatabase=connectToDatabase.connectToDatabase;exports.dropAllDatabaseIndexes=dropAllDatabaseIndexes.dropAllDatabaseIndexes;exports.listDatabaseIndexes=listDatabaseIndexes.listDatabaseIndexes;exports.listIndexesForCertainCollections=listDatabaseIndexes.listIndexesForCertainCollections;exports.printCollectionIndexes=listDatabaseIndexes.printCollectionIndexes;exports.onceConnected=onceConnected.onceConnected;//# sourceMappingURL=index.js.map
package/esm/index.d.ts CHANGED
@@ -3,7 +3,6 @@ export * from "./blueprint";
3
3
  export * from "./casts";
4
4
  export * from "./config";
5
5
  export * from "./connection";
6
- export * from "./console";
7
6
  export * from "./database";
8
7
  export * from "./migration";
9
8
  export * from "./model";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/esm/index.js CHANGED
@@ -1 +1 @@
1
- export{DeselectPipeline,deselectPipeline}from'./aggregate/DeselectPipeline.js';export{GeoNearPipeline,geoNearPipeline}from'./aggregate/GeoNearPipeline.js';export{GroupByPipeline,groupByPipeline}from'./aggregate/GroupByPipeline.js';export{LimitPipeline,limitPipeline}from'./aggregate/LimitPipeline.js';export{LookupPipeline,lookupPipeline}from'./aggregate/LookupPipeline.js';export{OrWherePipeline,orWherePipeline}from'./aggregate/OrWherePipeline.js';export{SelectPipeline,selectPipeline}from'./aggregate/SelectPipeline.js';export{SkipPipeline,skipPipeline}from'./aggregate/SkipPipeline.js';export{SortByPipeline,sortByPipeline}from'./aggregate/SortByPipeline.js';export{SortPipeline,sortPipeline}from'./aggregate/SortPipeline.js';export{SortRandomPipeline,sortRandomPipeline}from'./aggregate/SortRandomPipeline.js';export{UnwindPipeline,unwindPipeline}from'./aggregate/UnwindPipeline.js';export{WhereExpression,parseValuesInObject,toOperator}from'./aggregate/WhereExpression.js';export{WhereExpressionPipeline}from'./aggregate/WhereExpressionPipeline.js';export{WherePipeline,wherePipeline}from'./aggregate/WherePipeline.js';export{Aggregate}from'./aggregate/aggregate.js';export{$agg,_divide,_multiply,_round,addToSet,all,average,avg,between,booleanCond,columnName,columns,concat,concatWith,cond,condition,count,dayOfMonth,dayOfWeek,divide,eq,equal,exists,expr,first,firstDayOfMonth,firstMonth,firstYear,greaterThan,greaterThanOrEqual,gt,gte,inArray,isNull,last,lastDayOfMonth,lastMonth,lastYear,lessThan,lessThanOrEqual,like,lt,lte,max,merge,mergeWith,min,month,multiply,ne,nin,notBetween,notEqual,notExists,notIn,notInArray,notLike,notNull,push,regex,round,size,sum,week,year}from'./aggregate/expressions.js';export{parsePipeline,parsePipelines}from'./aggregate/parsePipelines.js';export{Pipeline}from'./aggregate/pipeline.js';export{whereOperators}from'./aggregate/types.js';export{Blueprint,blueprint}from'./blueprint/blueprint.js';export{ModelBlueprint,modelBlueprint}from'./blueprint/model-blueprint.js';export{arrayOf}from'./casts/arrayOf.js';export{castEmail}from'./casts/cast-email.js';export{castModel}from'./casts/castModel.js';export{expiresAfter}from'./casts/expiresAfter.js';export{castEnum,oneOf}from'./casts/oneOf.js';export{randomString}from'./casts/random-string.js';export{randomInteger}from'./casts/randomInteger.js';export{ShapedArrayType,shapedArray}from'./casts/shapedArray.js';export{getDatabaseConfigurations,setDatabaseConfigurations}from'./config.js';export{Connection,connection}from'./connection.js';export{registerDatabaseIndexesCommand}from'./console/db-indexes-command.js';export{registerMigrationCommand}from'./console/migrate-command.js';export{parseBlueprint}from'./console/register-blueprint-command.js';export{Database,database}from'./database.js';export{dropMigrations,listMigrations,migrate}from'./migration/migrate.js';export{MigrationOffice,migrationOffice}from'./migration/migration-office.js';export{ModelAggregate}from'./model/ModelAggregate.js';export{ModelSync}from'./model/ModelSync.js';export{BaseModel}from'./model/base-model.js';export{CrudModel}from'./model/crud-model.js';export{Joinable}from'./model/joinable.js';export{MasterMind,masterMind}from'./model/master-mind.js';export{Model}from'./model/model.js';export{ModelDeleteStrategy}from'./model/types.js';export{Query,query}from'./query/query.js';export{connectToDatabase}from'./utils/connectToDatabase.js';export{dropAllDatabaseIndexes}from'./utils/dropAllDatabaseIndexes.js';export{listDatabaseIndexes,listIndexesForCertainCollections,printCollectionIndexes}from'./utils/listDatabaseIndexes.js';export{onceConnected}from'./utils/onceConnected.js';//# sourceMappingURL=index.js.map
1
+ export{DeselectPipeline,deselectPipeline}from'./aggregate/DeselectPipeline.js';export{GeoNearPipeline,geoNearPipeline}from'./aggregate/GeoNearPipeline.js';export{GroupByPipeline,groupByPipeline}from'./aggregate/GroupByPipeline.js';export{LimitPipeline,limitPipeline}from'./aggregate/LimitPipeline.js';export{LookupPipeline,lookupPipeline}from'./aggregate/LookupPipeline.js';export{OrWherePipeline,orWherePipeline}from'./aggregate/OrWherePipeline.js';export{SelectPipeline,selectPipeline}from'./aggregate/SelectPipeline.js';export{SkipPipeline,skipPipeline}from'./aggregate/SkipPipeline.js';export{SortByPipeline,sortByPipeline}from'./aggregate/SortByPipeline.js';export{SortPipeline,sortPipeline}from'./aggregate/SortPipeline.js';export{SortRandomPipeline,sortRandomPipeline}from'./aggregate/SortRandomPipeline.js';export{UnwindPipeline,unwindPipeline}from'./aggregate/UnwindPipeline.js';export{WhereExpression,parseValuesInObject,toOperator}from'./aggregate/WhereExpression.js';export{WhereExpressionPipeline}from'./aggregate/WhereExpressionPipeline.js';export{WherePipeline,wherePipeline}from'./aggregate/WherePipeline.js';export{Aggregate}from'./aggregate/aggregate.js';export{$agg,_divide,_multiply,_round,addToSet,all,average,avg,between,booleanCond,columnName,columns,concat,concatWith,cond,condition,count,dayOfMonth,dayOfWeek,divide,eq,equal,exists,expr,first,firstDayOfMonth,firstMonth,firstYear,greaterThan,greaterThanOrEqual,gt,gte,inArray,isNull,last,lastDayOfMonth,lastMonth,lastYear,lessThan,lessThanOrEqual,like,lt,lte,max,merge,mergeWith,min,month,multiply,ne,nin,notBetween,notEqual,notExists,notIn,notInArray,notLike,notNull,push,regex,round,size,sum,week,year}from'./aggregate/expressions.js';export{parsePipeline,parsePipelines}from'./aggregate/parsePipelines.js';export{Pipeline}from'./aggregate/pipeline.js';export{whereOperators}from'./aggregate/types.js';export{Blueprint,blueprint}from'./blueprint/blueprint.js';export{ModelBlueprint,modelBlueprint}from'./blueprint/model-blueprint.js';export{arrayOf}from'./casts/arrayOf.js';export{castEmail}from'./casts/cast-email.js';export{castModel}from'./casts/castModel.js';export{expiresAfter}from'./casts/expiresAfter.js';export{castEnum,oneOf}from'./casts/oneOf.js';export{randomString}from'./casts/random-string.js';export{randomInteger}from'./casts/randomInteger.js';export{ShapedArrayType,shapedArray}from'./casts/shapedArray.js';export{getDatabaseConfigurations,setDatabaseConfigurations}from'./config.js';export{Connection,connection}from'./connection.js';export{Database,database}from'./database.js';export{dropMigrations,listMigrations,migrate}from'./migration/migrate.js';export{MigrationOffice,migrationOffice}from'./migration/migration-office.js';export{ModelAggregate}from'./model/ModelAggregate.js';export{ModelSync}from'./model/ModelSync.js';export{BaseModel}from'./model/base-model.js';export{CrudModel}from'./model/crud-model.js';export{Joinable}from'./model/joinable.js';export{MasterMind,masterMind}from'./model/master-mind.js';export{Model}from'./model/model.js';export{ModelDeleteStrategy}from'./model/types.js';export{Query,query}from'./query/query.js';export{connectToDatabase}from'./utils/connectToDatabase.js';export{dropAllDatabaseIndexes}from'./utils/dropAllDatabaseIndexes.js';export{listDatabaseIndexes,listIndexesForCertainCollections,printCollectionIndexes}from'./utils/listDatabaseIndexes.js';export{onceConnected}from'./utils/onceConnected.js';//# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warlock.js/cascade",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "ORM for managing databases",
5
5
  "main": "./cjs/index.js",
6
6
  "dependencies": {
@@ -8,6 +8,7 @@
8
8
  "@warlock.js/logger": "^1.0.3",
9
9
  "@mongez/reinforcements": "^2.3.8",
10
10
  "@mongez/supportive-is": "^2.0.0",
11
+ "@faker-js/faker": "^8.4.1",
11
12
  "@mongez/time-wizard": "^1.0.6",
12
13
  "dayjs": "^1.11.9",
13
14
  "console-table-printer": "^2.11.2",
@@ -1,3 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function registerDatabaseIndexesCommand(): Command;
3
- //# sourceMappingURL=db-indexes-command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"db-indexes-command.d.ts","sourceRoot":"","sources":["../../src/console/db-indexes-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,wBAAgB,8BAA8B,YAwB7C"}
@@ -1,18 +0,0 @@
1
- 'use strict';var commander=require('commander'),connectToDatabase=require('../utils/connectToDatabase.js'),dropAllDatabaseIndexes=require('../utils/dropAllDatabaseIndexes.js'),listDatabaseIndexes=require('../utils/listDatabaseIndexes.js');require('@mongez/copper'),require('@mongez/events'),require('@warlock.js/logger'),require('mongodb'),require('async_hooks');function registerDatabaseIndexesCommand() {
2
- return new commander.Command("db:indexes")
3
- .description("List all database indexes")
4
- .option("-c, --collections <collections>", "List indexes for specific collections")
5
- .option("-d, --drop", "Drop all database indexes")
6
- .action(options => {
7
- connectToDatabase.connectToDatabase();
8
- if (options.drop) {
9
- return dropAllDatabaseIndexes.dropAllDatabaseIndexes();
10
- }
11
- if (options.collections) {
12
- return listDatabaseIndexes.listIndexesForCertainCollections(Array.isArray(options.collections)
13
- ? options.collections
14
- : [options.collections]);
15
- }
16
- listDatabaseIndexes.listDatabaseIndexes();
17
- });
18
- }exports.registerDatabaseIndexesCommand=registerDatabaseIndexesCommand;//# sourceMappingURL=db-indexes-command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"db-indexes-command.js","sources":["../../src/console/db-indexes-command.ts"],"sourcesContent":[null],"names":["Command","connectToDatabase","dropAllDatabaseIndexes","listIndexesForCertainCollections","listDatabaseIndexes"],"mappings":"oXAQgB,8BAA8B,GAAA;AAC5C,IAAA,OAAO,IAAIA,iBAAO,CAAC,YAAY,CAAC;SAC7B,WAAW,CAAC,2BAA2B,CAAC;AACxC,SAAA,MAAM,CACL,iCAAiC,EACjC,uCAAuC,CACxC;AACA,SAAA,MAAM,CAAC,YAAY,EAAE,2BAA2B,CAAC;SACjD,MAAM,CAAC,OAAO,IAAG;AAChB,QAAAC,mCAAiB,EAAE,CAAC;QACpB,IAAI,OAAO,CAAC,IAAI,EAAE;YAChB,OAAOC,6CAAsB,EAAE,CAAC;AACjC,SAAA;QAED,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,OAAOC,oDAAgC,CACrC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;kBAC9B,OAAO,CAAC,WAAW;AACrB,kBAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAC1B,CAAC;AACH,SAAA;AAED,QAAAC,uCAAmB,EAAE,CAAC;AACxB,KAAC,CAAC,CAAC;AACP"}
@@ -1,4 +0,0 @@
1
- export * from "./db-indexes-command";
2
- export * from "./migrate-command";
3
- export * from "./register-blueprint-command";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/console/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function registerMigrationCommand(): any;
2
- //# sourceMappingURL=migrate-command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate-command.d.ts","sourceRoot":"","sources":["../../src/console/migrate-command.ts"],"names":[],"mappings":"AAIA,wBAAgB,wBAAwB,QAavC"}
@@ -1,13 +0,0 @@
1
- 'use strict';var core=require('@warlock.js/core'),migrate=require('../migration/migrate.js'),connectToDatabase=require('../utils/connectToDatabase.js');require('process'),require('async_hooks'),require('@mongez/copper'),require('@mongez/events'),require('@warlock.js/logger'),require('mongodb'),require('console-table-printer');function registerMigrationCommand() {
2
- return core.command("migrate")
3
- .description("Generate Database Migrations")
4
- .option("-f, --fresh", "Drop all migrations and generate fresh migrations")
5
- .option("-l, --list", "List all migrations")
6
- .action(({ options }) => {
7
- connectToDatabase.connectToDatabase();
8
- if (options.list) {
9
- return migrate.listMigrations();
10
- }
11
- migrate.migrate(options.fresh);
12
- });
13
- }exports.registerMigrationCommand=registerMigrationCommand;//# sourceMappingURL=migrate-command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate-command.js","sources":["../../src/console/migrate-command.ts"],"sourcesContent":[null],"names":["command","connectToDatabase","listMigrations","migrate"],"mappings":"iVAIgB,wBAAwB,GAAA;IACtC,OAAOA,YAAO,CAAC,SAAS,CAAC;SACtB,WAAW,CAAC,8BAA8B,CAAC;AAC3C,SAAA,MAAM,CAAC,aAAa,EAAE,mDAAmD,CAAC;AAC1E,SAAA,MAAM,CAAC,YAAY,EAAE,qBAAqB,CAAC;AAC3C,SAAA,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,KAAI;AACtB,QAAAC,mCAAiB,EAAE,CAAC;QACpB,IAAI,OAAO,CAAC,IAAI,EAAE;YAChB,OAAOC,sBAAc,EAAE,CAAC;AACzB,SAAA;AAED,QAAAC,eAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACzB,KAAC,CAAC,CAAC;AACP"}
@@ -1,2 +0,0 @@
1
- export declare function parseBlueprint(data: any): any;
2
- //# sourceMappingURL=register-blueprint-command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register-blueprint-command.d.ts","sourceRoot":"","sources":["../../src/console/register-blueprint-command.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,OAoBvC"}
@@ -1,19 +0,0 @@
1
- 'use strict';var supportiveIs=require('@mongez/supportive-is'),blueprint=require('../blueprint/blueprint.js');function parseBlueprint(data) {
2
- const schema = {};
3
- for (const column in data) {
4
- let columnType = data[column];
5
- // check first if the column type is typeof Blueprint as columnType will be the class itself
6
- // not the object of Blueprint
7
- if (columnType.prototype instanceof blueprint.Blueprint) {
8
- columnType = parseBlueprint(columnType.schema);
9
- }
10
- else if (supportiveIs.isPlainObject(columnType)) {
11
- columnType = parseBlueprint(columnType);
12
- }
13
- else if (typeof columnType !== "string" && !supportiveIs.isPlainObject(columnType)) {
14
- columnType = columnType.name;
15
- }
16
- schema[column] = columnType;
17
- }
18
- return schema;
19
- }exports.parseBlueprint=parseBlueprint;//# sourceMappingURL=register-blueprint-command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register-blueprint-command.js","sources":["../../src/console/register-blueprint-command.ts"],"sourcesContent":[null],"names":["Blueprint","isPlainObject"],"mappings":"8GAGM,SAAU,cAAc,CAAC,IAAS,EAAA;IACtC,MAAM,MAAM,GAAQ,EAAE,CAAC;AACvB,IAAA,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE;AACzB,QAAA,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;;;AAK9B,QAAA,IAAI,UAAU,CAAC,SAAS,YAAYA,mBAAS,EAAE;AAC7C,YAAA,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAChD,SAAA;AAAM,aAAA,IAAIC,0BAAa,CAAC,UAAU,CAAC,EAAE;AACpC,YAAA,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;AACzC,SAAA;aAAM,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAACA,0BAAa,CAAC,UAAU,CAAC,EAAE;AACvE,YAAA,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC;AAC9B,SAAA;AAED,QAAA,MAAM,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC;AAC7B,KAAA;AAED,IAAA,OAAO,MAAM,CAAC;AAChB"}
@@ -1,69 +0,0 @@
1
- import { ModelAggregate } from "./ModelAggregate";
2
- import { ModelSync } from "./ModelSync";
3
- import { RelationshipWithMany } from "./RelationshipWithMany";
4
- import { CrudModel } from "./crud-model";
5
- import { Model } from "./model";
6
- import type { ChildModel, ModelDocument } from "./types";
7
- export declare abstract class RelationshipModel extends CrudModel {
8
- /**
9
- * Sync with list
10
- */
11
- syncWith: ModelSync[];
12
- /**
13
- * Get relationship with the given model class
14
- */
15
- hasMany<T extends Model = Model>(modelClass: typeof Model, column: string): RelationshipWithMany<T>;
16
- /**
17
- * Get new aggregate for current model
18
- */
19
- static aggregate<T extends Model = Model>(this: ChildModel<T>): ModelAggregate<T>;
20
- /**
21
- * Get query builder
22
- * @alias aggregate
23
- */
24
- static queryBuilder<T extends Model = Model>(this: ChildModel<T>): ModelAggregate<T>;
25
- /**
26
- * Sync with the given model
27
- */
28
- static sync(columns: string | string[], embedMethod?: string): ModelSync;
29
- /**
30
- * Sync data on saving
31
- */
32
- startSyncing(saveMode: "create" | "update", oldModel?: Model): void;
33
- /**
34
- * Sync destruction
35
- * Called when destroy method is called
36
- */
37
- syncDestruction(): void;
38
- /**
39
- * The syncing model (That calls startSyncing) is being embedded in multiple documents of current model
40
- * I.e Country.syncMany('cities') while current model is City
41
- */
42
- static syncMany(columns: string | string[], embedMethod?: string): ModelSync;
43
- /**
44
- * Reassociate a model/object/document with the current model
45
- * If the model is already associated, it will be updated
46
- * If not, it will be associated
47
- * the model/document must have an id
48
- *
49
- * If it is a model, you can set the embed method to use
50
- */
51
- reassociate(this: Model, column: string, model: Model | ModelDocument | any, embedWith?: string): Model;
52
- /**
53
- * Associate a model with the current model
54
- */
55
- associate(this: Model, column: string, model: Model | ModelDocument | any, embedWith?: string): Model;
56
- /**
57
- * Disassociate a model with the current model
58
- */
59
- disassociate(this: Model, column: string, model: Model | ModelDocument | any): Model;
60
- /**
61
- * Make a wrapper to list when models should be updated when only one of the given columns is updated
62
- */
63
- syncUpdateWhenChange(columns: string | string[], syncModels: ModelSync[]): ModelSync[];
64
- /**
65
- * Get a Joinable instance for current model
66
- */
67
- static joinable(localField?: string, foreignField?: string, single?: boolean, as?: string): import("./joinable").JoinableProxy;
68
- }
69
- //# sourceMappingURL=relationships.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/model/relationships.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAEzD,8BAAsB,iBAAkB,SAAQ,SAAS;IACvD;;OAEG;IACI,QAAQ,EAAE,SAAS,EAAE,CAAM;IAElC;;OAEG;IACI,OAAO,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EACpC,UAAU,EAAE,OAAO,KAAK,EACxB,MAAM,EAAE,MAAM;IAKhB;;OAEG;WACW,SAAS,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;IAIpE;;;OAGG;WACW,YAAY,CAAC,CAAC,SAAS,KAAK,GAAG,KAAK,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;IAIvE;;OAEG;WACW,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,WAAW,SAAc;IAIxE;;OAEG;IACI,YAAY,CAAC,QAAQ,EAAE,QAAQ,GAAG,QAAQ,EAAE,QAAQ,CAAC,EAAE,KAAK;IAMnE;;;OAGG;IACI,eAAe;IAMtB;;;OAGG;WACW,QAAQ,CACpB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,WAAW,SAAc;IAK3B;;;;;;;OAOG;IACI,WAAW,CAChB,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GAAG,aAAa,GAAG,GAAG,EAClC,SAAS,CAAC,EAAE,MAAM;IA6BpB;;OAEG;IACI,SAAS,CACd,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GAAG,aAAa,GAAG,GAAG,EAClC,SAAS,CAAC,EAAE,MAAM;IAoBpB;;OAEG;IACI,YAAY,CACjB,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GAAG,aAAa,GAAG,GAAG;IAuBpC;;OAEG;IACI,oBAAoB,CACzB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,UAAU,EAAE,SAAS,EAAE;IASzB;;OAEG;WACW,QAAQ,CACpB,UAAU,CAAC,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,OAAO,EAChB,EAAE,CAAC,EAAE,MAAM;CAsBd"}
@@ -1,144 +0,0 @@
1
- 'use strict';var reinforcements=require('@mongez/reinforcements'),joinableProxy=require('../utils/joinable-proxy.js'),ModelAggregate=require('./ModelAggregate.js'),ModelSync=require('./ModelSync.js'),RelationshipWithMany=require('./RelationshipWithMany.js'),crudModel=require('./crud-model.js'),joinable=require('./joinable.js'),model=require('./model.js');class RelationshipModel extends crudModel.CrudModel {
2
- /**
3
- * Sync with list
4
- */
5
- syncWith = [];
6
- /**
7
- * Get relationship with the given model class
8
- */
9
- hasMany(modelClass, column) {
10
- return new RelationshipWithMany.RelationshipWithMany(this, modelClass, column);
11
- }
12
- /**
13
- * Get new aggregate for current model
14
- */
15
- static aggregate() {
16
- return new ModelAggregate.ModelAggregate(this);
17
- }
18
- /**
19
- * Get query builder
20
- * @alias aggregate
21
- */
22
- static queryBuilder() {
23
- return new ModelAggregate.ModelAggregate(this);
24
- }
25
- /**
26
- * Sync with the given model
27
- */
28
- static sync(columns, embedMethod = "embedData") {
29
- return new ModelSync.ModelSync(this, columns, embedMethod);
30
- }
31
- /**
32
- * Sync data on saving
33
- */
34
- startSyncing(saveMode, oldModel) {
35
- for (const modelSync of this.syncWith) {
36
- modelSync.sync(this, saveMode, oldModel);
37
- }
38
- }
39
- /**
40
- * Sync destruction
41
- * Called when destroy method is called
42
- */
43
- syncDestruction() {
44
- for (const modelSync of this.syncWith) {
45
- modelSync.syncDestruction(this);
46
- }
47
- }
48
- /**
49
- * The syncing model (That calls startSyncing) is being embedded in multiple documents of current model
50
- * I.e Country.syncMany('cities') while current model is City
51
- */
52
- static syncMany(columns, embedMethod = "embedData") {
53
- return new ModelSync.ModelSync(this, columns, embedMethod).syncMany();
54
- }
55
- /**
56
- * Reassociate a model/object/document with the current model
57
- * If the model is already associated, it will be updated
58
- * If not, it will be associated
59
- * the model/document must have an id
60
- *
61
- * If it is a model, you can set the embed method to use
62
- */
63
- reassociate(column, model$1, embedWith) {
64
- const columnValue = model$1 instanceof model.Model
65
- ? embedWith
66
- ? model$1[embedWith]()
67
- : model$1.embeddedData
68
- : model$1;
69
- if (columnValue === undefined)
70
- return this;
71
- // make a deep copy so when changing the data, it won't affect the original data
72
- const documentsList = reinforcements.clone(this.get(column, []));
73
- const index = documentsList.findIndex((doc) => (doc?.id || doc) === (columnValue?.id || columnValue));
74
- if (index === -1) {
75
- documentsList.push(columnValue);
76
- }
77
- else {
78
- documentsList[index] = columnValue;
79
- }
80
- this.set(column, [...documentsList]);
81
- return this;
82
- }
83
- /**
84
- * Associate a model with the current model
85
- */
86
- associate(column, model$1, embedWith) {
87
- const columnValue = model$1 instanceof model.Model
88
- ? embedWith
89
- ? model$1[embedWith]()
90
- : model$1.embeddedData
91
- : model$1;
92
- if (columnValue === undefined)
93
- return this;
94
- const documentsList = this.get(column, []);
95
- documentsList.push(columnValue);
96
- this.set(column, documentsList);
97
- return this;
98
- }
99
- /**
100
- * Disassociate a model with the current model
101
- */
102
- disassociate(column, model$1) {
103
- const columnValue = model$1 instanceof model.Model ? model$1.embeddedData : model$1;
104
- if (columnValue === undefined)
105
- return this;
106
- const documentsList = this.get(column, []);
107
- if (!Array.isArray(documentsList))
108
- return this;
109
- const index = documentsList.findIndex((doc) => (doc?.id || doc) === (columnValue?.id || columnValue));
110
- if (index !== -1) {
111
- documentsList.splice(index, 1);
112
- }
113
- this.set(column, documentsList);
114
- return this;
115
- }
116
- /**
117
- * Make a wrapper to list when models should be updated when only one of the given columns is updated
118
- */
119
- syncUpdateWhenChange(columns, syncModels) {
120
- return syncModels.map(syncModel => {
121
- syncModel.updateWhenChange(columns);
122
- return syncModel;
123
- });
124
- }
125
- /**
126
- * Get a Joinable instance for current model
127
- */
128
- static joinable(localField, foreignField, single, as) {
129
- const joinable$1 = new joinable.Joinable(this);
130
- if (localField) {
131
- joinable$1.localField(localField);
132
- }
133
- if (foreignField) {
134
- joinable$1.foreignField(foreignField);
135
- }
136
- if (single) {
137
- joinable$1.single(single);
138
- }
139
- if (as) {
140
- joinable$1.as(as);
141
- }
142
- return joinableProxy.joinableProxy(joinable$1);
143
- }
144
- }exports.RelationshipModel=RelationshipModel;//# sourceMappingURL=relationships.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"relationships.js","sources":["../../src/model/relationships.ts"],"sourcesContent":[null],"names":["CrudModel","RelationshipWithMany","ModelAggregate","ModelSync","model","Model","clone","joinable","Joinable","joinableProxy"],"mappings":"qWAUM,MAAgB,iBAAkB,SAAQA,mBAAS,CAAA;AACvD;;AAEG;IACI,QAAQ,GAAgB,EAAE,CAAC;AAElC;;AAEG;IACI,OAAO,CACZ,UAAwB,EACxB,MAAc,EAAA;QAEd,OAAO,IAAIC,yCAAoB,CAAI,IAAW,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;KACrE;AAED;;AAEG;AACI,IAAA,OAAO,SAAS,GAAA;AACrB,QAAA,OAAO,IAAIC,6BAAc,C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zB,SAAA;AAED,QAAA,IAAI,EAAE,EAAE;AACN,YAAAA,UAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACjB,SAAA;AAED,QAAA,OAAOE,2BAAa,CAACF,UAAQ,CAAC,CAAC;KAChC;AACF"}
@@ -1,3 +0,0 @@
1
- import { Command } from "commander";
2
- export declare function registerDatabaseIndexesCommand(): Command;
3
- //# sourceMappingURL=db-indexes-command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"db-indexes-command.d.ts","sourceRoot":"","sources":["../../src/console/db-indexes-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,wBAAgB,8BAA8B,YAwB7C"}
@@ -1,18 +0,0 @@
1
- import {Command}from'commander';import {connectToDatabase}from'../utils/connectToDatabase.js';import {dropAllDatabaseIndexes}from'../utils/dropAllDatabaseIndexes.js';import {listIndexesForCertainCollections,listDatabaseIndexes}from'../utils/listDatabaseIndexes.js';import'@mongez/copper';import'@mongez/events';import'@warlock.js/logger';import'mongodb';import'async_hooks';function registerDatabaseIndexesCommand() {
2
- return new Command("db:indexes")
3
- .description("List all database indexes")
4
- .option("-c, --collections <collections>", "List indexes for specific collections")
5
- .option("-d, --drop", "Drop all database indexes")
6
- .action(options => {
7
- connectToDatabase();
8
- if (options.drop) {
9
- return dropAllDatabaseIndexes();
10
- }
11
- if (options.collections) {
12
- return listIndexesForCertainCollections(Array.isArray(options.collections)
13
- ? options.collections
14
- : [options.collections]);
15
- }
16
- listDatabaseIndexes();
17
- });
18
- }export{registerDatabaseIndexesCommand};//# sourceMappingURL=db-indexes-command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"db-indexes-command.js","sources":["../../src/console/db-indexes-command.ts"],"sourcesContent":[null],"names":[],"mappings":"+XAQgB,8BAA8B,GAAA;AAC5C,IAAA,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC;SAC7B,WAAW,CAAC,2BAA2B,CAAC;AACxC,SAAA,MAAM,CACL,iCAAiC,EACjC,uCAAuC,CACxC;AACA,SAAA,MAAM,CAAC,YAAY,EAAE,2BAA2B,CAAC;SACjD,MAAM,CAAC,OAAO,IAAG;AAChB,QAAA,iBAAiB,EAAE,CAAC;QACpB,IAAI,OAAO,CAAC,IAAI,EAAE;YAChB,OAAO,sBAAsB,EAAE,CAAC;AACjC,SAAA;QAED,IAAI,OAAO,CAAC,WAAW,EAAE;YACvB,OAAO,gCAAgC,CACrC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC;kBAC9B,OAAO,CAAC,WAAW;AACrB,kBAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAC1B,CAAC;AACH,SAAA;AAED,QAAA,mBAAmB,EAAE,CAAC;AACxB,KAAC,CAAC,CAAC;AACP"}
@@ -1,4 +0,0 @@
1
- export * from "./db-indexes-command";
2
- export * from "./migrate-command";
3
- export * from "./register-blueprint-command";
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/console/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function registerMigrationCommand(): any;
2
- //# sourceMappingURL=migrate-command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate-command.d.ts","sourceRoot":"","sources":["../../src/console/migrate-command.ts"],"names":[],"mappings":"AAIA,wBAAgB,wBAAwB,QAavC"}
@@ -1,13 +0,0 @@
1
- import {command}from'@warlock.js/core';import {listMigrations,migrate}from'../migration/migrate.js';import {connectToDatabase}from'../utils/connectToDatabase.js';import'process';import'async_hooks';import'@mongez/copper';import'@mongez/events';import'@warlock.js/logger';import'mongodb';import'console-table-printer';function registerMigrationCommand() {
2
- return command("migrate")
3
- .description("Generate Database Migrations")
4
- .option("-f, --fresh", "Drop all migrations and generate fresh migrations")
5
- .option("-l, --list", "List all migrations")
6
- .action(({ options }) => {
7
- connectToDatabase();
8
- if (options.list) {
9
- return listMigrations();
10
- }
11
- migrate(options.fresh);
12
- });
13
- }export{registerMigrationCommand};//# sourceMappingURL=migrate-command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"migrate-command.js","sources":["../../src/console/migrate-command.ts"],"sourcesContent":[null],"names":[],"mappings":"sUAIgB,wBAAwB,GAAA;IACtC,OAAO,OAAO,CAAC,SAAS,CAAC;SACtB,WAAW,CAAC,8BAA8B,CAAC;AAC3C,SAAA,MAAM,CAAC,aAAa,EAAE,mDAAmD,CAAC;AAC1E,SAAA,MAAM,CAAC,YAAY,EAAE,qBAAqB,CAAC;AAC3C,SAAA,MAAM,CAAC,CAAC,EAAE,OAAO,EAAE,KAAI;AACtB,QAAA,iBAAiB,EAAE,CAAC;QACpB,IAAI,OAAO,CAAC,IAAI,EAAE;YAChB,OAAO,cAAc,EAAE,CAAC;AACzB,SAAA;AAED,QAAA,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACzB,KAAC,CAAC,CAAC;AACP"}
@@ -1,2 +0,0 @@
1
- export declare function parseBlueprint(data: any): any;
2
- //# sourceMappingURL=register-blueprint-command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register-blueprint-command.d.ts","sourceRoot":"","sources":["../../src/console/register-blueprint-command.ts"],"names":[],"mappings":"AAGA,wBAAgB,cAAc,CAAC,IAAI,EAAE,GAAG,OAoBvC"}
@@ -1,19 +0,0 @@
1
- import {isPlainObject}from'@mongez/supportive-is';import {Blueprint}from'../blueprint/blueprint.js';function parseBlueprint(data) {
2
- const schema = {};
3
- for (const column in data) {
4
- let columnType = data[column];
5
- // check first if the column type is typeof Blueprint as columnType will be the class itself
6
- // not the object of Blueprint
7
- if (columnType.prototype instanceof Blueprint) {
8
- columnType = parseBlueprint(columnType.schema);
9
- }
10
- else if (isPlainObject(columnType)) {
11
- columnType = parseBlueprint(columnType);
12
- }
13
- else if (typeof columnType !== "string" && !isPlainObject(columnType)) {
14
- columnType = columnType.name;
15
- }
16
- schema[column] = columnType;
17
- }
18
- return schema;
19
- }export{parseBlueprint};//# sourceMappingURL=register-blueprint-command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register-blueprint-command.js","sources":["../../src/console/register-blueprint-command.ts"],"sourcesContent":[null],"names":[],"mappings":"oGAGM,SAAU,cAAc,CAAC,IAAS,EAAA;IACtC,MAAM,MAAM,GAAQ,EAAE,CAAC;AACvB,IAAA,KAAK,MAAM,MAAM,IAAI,IAAI,EAAE;AACzB,QAAA,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;;;AAK9B,QAAA,IAAI,UAAU,CAAC,SAAS,YAAY,SAAS,EAAE;AAC7C,YAAA,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAChD,SAAA;AAAM,aAAA,IAAI,aAAa,CAAC,UAAU,CAAC,EAAE;AACpC,YAAA,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;AACzC,SAAA;aAAM,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;AACvE,YAAA,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC;AAC9B,SAAA;AAED,QAAA,MAAM,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC;AAC7B,KAAA;AAED,IAAA,OAAO,MAAM,CAAC;AAChB"}
@@ -1,69 +0,0 @@
1
- import { ModelAggregate } from "./ModelAggregate";
2
- import { ModelSync } from "./ModelSync";
3
- import { RelationshipWithMany } from "./RelationshipWithMany";
4
- import { CrudModel } from "./crud-model";
5
- import { Model } from "./model";
6
- import type { ChildModel, ModelDocument } from "./types";
7
- export declare abstract class RelationshipModel extends CrudModel {
8
- /**
9
- * Sync with list
10
- */
11
- syncWith: ModelSync[];
12
- /**
13
- * Get relationship with the given model class
14
- */
15
- hasMany<T extends Model = Model>(modelClass: typeof Model, column: string): RelationshipWithMany<T>;
16
- /**
17
- * Get new aggregate for current model
18
- */
19
- static aggregate<T extends Model = Model>(this: ChildModel<T>): ModelAggregate<T>;
20
- /**
21
- * Get query builder
22
- * @alias aggregate
23
- */
24
- static queryBuilder<T extends Model = Model>(this: ChildModel<T>): ModelAggregate<T>;
25
- /**
26
- * Sync with the given model
27
- */
28
- static sync(columns: string | string[], embedMethod?: string): ModelSync;
29
- /**
30
- * Sync data on saving
31
- */
32
- startSyncing(saveMode: "create" | "update", oldModel?: Model): void;
33
- /**
34
- * Sync destruction
35
- * Called when destroy method is called
36
- */
37
- syncDestruction(): void;
38
- /**
39
- * The syncing model (That calls startSyncing) is being embedded in multiple documents of current model
40
- * I.e Country.syncMany('cities') while current model is City
41
- */
42
- static syncMany(columns: string | string[], embedMethod?: string): ModelSync;
43
- /**
44
- * Reassociate a model/object/document with the current model
45
- * If the model is already associated, it will be updated
46
- * If not, it will be associated
47
- * the model/document must have an id
48
- *
49
- * If it is a model, you can set the embed method to use
50
- */
51
- reassociate(this: Model, column: string, model: Model | ModelDocument | any, embedWith?: string): Model;
52
- /**
53
- * Associate a model with the current model
54
- */
55
- associate(this: Model, column: string, model: Model | ModelDocument | any, embedWith?: string): Model;
56
- /**
57
- * Disassociate a model with the current model
58
- */
59
- disassociate(this: Model, column: string, model: Model | ModelDocument | any): Model;
60
- /**
61
- * Make a wrapper to list when models should be updated when only one of the given columns is updated
62
- */
63
- syncUpdateWhenChange(columns: string | string[], syncModels: ModelSync[]): ModelSync[];
64
- /**
65
- * Get a Joinable instance for current model
66
- */
67
- static joinable(localField?: string, foreignField?: string, single?: boolean, as?: string): import("./joinable").JoinableProxy;
68
- }
69
- //# sourceMappingURL=relationships.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/model/relationships.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CA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aAAa,GAAG,GAAG,EAClC,SAAS,CAAC,EAAE,MAAM;IAoBpB;;OAEG;IACI,YAAY,CACjB,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,KAAK,GAAG,aAAa,GAAG,GAAG;IAuBpC;;OAEG;IACI,oBAAoB,CACzB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,UAAU,EAAE,SAAS,EAAE;IASzB;;OAEG;WACW,QAAQ,CACpB,UAAU,CAAC,EAAE,MAAM,EACnB,YAAY,CAAC,EAAE,MAAM,EACrB,MAAM,CAAC,EAAE,OAAO,EAChB,EAAE,CAAC,EAAE,MAAM;CAsBd"}
@@ -1,144 +0,0 @@
1
- import {clone}from'@mongez/reinforcements';import {joinableProxy}from'../utils/joinable-proxy.js';import {ModelAggregate}from'./ModelAggregate.js';import {ModelSync}from'./ModelSync.js';import {RelationshipWithMany}from'./RelationshipWithMany.js';import {CrudModel}from'./crud-model.js';import {Joinable}from'./joinable.js';import {Model}from'./model.js';class RelationshipModel extends CrudModel {
2
- /**
3
- * Sync with list
4
- */
5
- syncWith = [];
6
- /**
7
- * Get relationship with the given model class
8
- */
9
- hasMany(modelClass, column) {
10
- return new RelationshipWithMany(this, modelClass, column);
11
- }
12
- /**
13
- * Get new aggregate for current model
14
- */
15
- static aggregate() {
16
- return new ModelAggregate(this);
17
- }
18
- /**
19
- * Get query builder
20
- * @alias aggregate
21
- */
22
- static queryBuilder() {
23
- return new ModelAggregate(this);
24
- }
25
- /**
26
- * Sync with the given model
27
- */
28
- static sync(columns, embedMethod = "embedData") {
29
- return new ModelSync(this, columns, embedMethod);
30
- }
31
- /**
32
- * Sync data on saving
33
- */
34
- startSyncing(saveMode, oldModel) {
35
- for (const modelSync of this.syncWith) {
36
- modelSync.sync(this, saveMode, oldModel);
37
- }
38
- }
39
- /**
40
- * Sync destruction
41
- * Called when destroy method is called
42
- */
43
- syncDestruction() {
44
- for (const modelSync of this.syncWith) {
45
- modelSync.syncDestruction(this);
46
- }
47
- }
48
- /**
49
- * The syncing model (That calls startSyncing) is being embedded in multiple documents of current model
50
- * I.e Country.syncMany('cities') while current model is City
51
- */
52
- static syncMany(columns, embedMethod = "embedData") {
53
- return new ModelSync(this, columns, embedMethod).syncMany();
54
- }
55
- /**
56
- * Reassociate a model/object/document with the current model
57
- * If the model is already associated, it will be updated
58
- * If not, it will be associated
59
- * the model/document must have an id
60
- *
61
- * If it is a model, you can set the embed method to use
62
- */
63
- reassociate(column, model, embedWith) {
64
- const columnValue = model instanceof Model
65
- ? embedWith
66
- ? model[embedWith]()
67
- : model.embeddedData
68
- : model;
69
- if (columnValue === undefined)
70
- return this;
71
- // make a deep copy so when changing the data, it won't affect the original data
72
- const documentsList = clone(this.get(column, []));
73
- const index = documentsList.findIndex((doc) => (doc?.id || doc) === (columnValue?.id || columnValue));
74
- if (index === -1) {
75
- documentsList.push(columnValue);
76
- }
77
- else {
78
- documentsList[index] = columnValue;
79
- }
80
- this.set(column, [...documentsList]);
81
- return this;
82
- }
83
- /**
84
- * Associate a model with the current model
85
- */
86
- associate(column, model, embedWith) {
87
- const columnValue = model instanceof Model
88
- ? embedWith
89
- ? model[embedWith]()
90
- : model.embeddedData
91
- : model;
92
- if (columnValue === undefined)
93
- return this;
94
- const documentsList = this.get(column, []);
95
- documentsList.push(columnValue);
96
- this.set(column, documentsList);
97
- return this;
98
- }
99
- /**
100
- * Disassociate a model with the current model
101
- */
102
- disassociate(column, model) {
103
- const columnValue = model instanceof Model ? model.embeddedData : model;
104
- if (columnValue === undefined)
105
- return this;
106
- const documentsList = this.get(column, []);
107
- if (!Array.isArray(documentsList))
108
- return this;
109
- const index = documentsList.findIndex((doc) => (doc?.id || doc) === (columnValue?.id || columnValue));
110
- if (index !== -1) {
111
- documentsList.splice(index, 1);
112
- }
113
- this.set(column, documentsList);
114
- return this;
115
- }
116
- /**
117
- * Make a wrapper to list when models should be updated when only one of the given columns is updated
118
- */
119
- syncUpdateWhenChange(columns, syncModels) {
120
- return syncModels.map(syncModel => {
121
- syncModel.updateWhenChange(columns);
122
- return syncModel;
123
- });
124
- }
125
- /**
126
- * Get a Joinable instance for current model
127
- */
128
- static joinable(localField, foreignField, single, as) {
129
- const joinable = new Joinable(this);
130
- if (localField) {
131
- joinable.localField(localField);
132
- }
133
- if (foreignField) {
134
- joinable.foreignField(foreignField);
135
- }
136
- if (single) {
137
- joinable.single(single);
138
- }
139
- if (as) {
140
- joinable.as(as);
141
- }
142
- return joinableProxy(joinable);
143
- }
144
- }export{RelationshipModel};//# sourceMappingURL=relationships.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"relationships.js","sources":["../../src/model/relationships.ts"],"sourcesContent":[null],"names":[],"mappings":"mWAUM,MAAgB,iBAAkB,SAAQ,SAAS,CAAA;AACvD;;AAEG;IACI,QAAQ,GAAgB,EAAE,CAAC;AAElC;;AAEG;IACI,OAAO,CACZ,UAAwB,EACxB,MAAc,EAAA;QAEd,OAAO,IAAI,oBAAoB,CAAI,IAAW,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;KACrE;AAED;;AAEG;AACI,IAAA,OAAO,SAAS,GAAA;AACrB,QAAA,OAAO,IAAI,cAAc,CAAI,IAAI,CAAC,CAAC;KACpC;AAED;;;AAGG;AACI,IAAA,OAAO,YAAY,GAAA;AACxB,QAAA,OAAO,IAAI,cAAc,CAAI,IAAI,CAAC,CAAC;KACpC;AAED;;AAEG;AACI,IAAA,OAAO,IAAI,CAAC,OAA0B,EAAE,WAAW,GAAG,WAAW,EAAA;QACtE,OAAO,IAAI,SAAS,CAAC,IAAoB,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;KAClE;AAED;;AAEG;IACI,YAAY,CAAC,QAA6B,EAAE,QAAgB,EAAA;AACjE,QAAA,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE;YACrC,SAAS,CAAC,IAAI,CAAC,IAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACjD,S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