@rvoh/dream 2.24.1 → 2.25.0
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/cjs/src/dream/Query.js +247 -67
- package/dist/cjs/src/errors/BatchingIncompatibleWithLimitOrOffset.js +25 -0
- package/dist/cjs/src/errors/MissingRequiredLockOptionForUpdateCallback.js +16 -0
- package/dist/esm/src/dream/Query.js +247 -67
- package/dist/esm/src/errors/BatchingIncompatibleWithLimitOrOffset.js +25 -0
- package/dist/esm/src/errors/MissingRequiredLockOptionForUpdateCallback.js +16 -0
- package/dist/types/src/dream/Query.d.ts +316 -40
- package/dist/types/src/errors/BatchingIncompatibleWithLimitOrOffset.d.ts +3 -0
- package/dist/types/src/errors/MissingRequiredLockOptionForUpdateCallback.d.ts +3 -0
- package/docs/classes/db.DreamMigrationHelpers.html +11 -11
- package/docs/classes/db.KyselyQueryDriver.html +40 -40
- package/docs/classes/db.PostgresQueryDriver.html +41 -41
- package/docs/classes/db.QueryDriverBase.html +39 -39
- package/docs/classes/errors.CheckConstraintViolation.html +3 -3
- package/docs/classes/errors.ColumnOverflow.html +3 -3
- package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +3 -3
- package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +3 -3
- package/docs/classes/errors.DataTypeColumnTypeMismatch.html +3 -3
- package/docs/classes/errors.DecryptionError.html +2 -2
- package/docs/classes/errors.DecryptionParseError.html +2 -2
- package/docs/classes/errors.DecryptionRotationError.html +3 -3
- package/docs/classes/errors.GlobalNameNotSet.html +3 -3
- package/docs/classes/errors.InvalidCalendarDate.html +2 -2
- package/docs/classes/errors.InvalidClockTime.html +2 -2
- package/docs/classes/errors.InvalidClockTimeTz.html +2 -2
- package/docs/classes/errors.InvalidDateTime.html +2 -2
- package/docs/classes/errors.MissingSerializersDefinition.html +3 -3
- package/docs/classes/errors.NonLoadedAssociation.html +3 -3
- package/docs/classes/errors.NotNullViolation.html +3 -3
- package/docs/classes/errors.RecordNotFound.html +3 -3
- package/docs/classes/errors.ValidationError.html +3 -3
- package/docs/classes/index.CalendarDate.html +33 -33
- package/docs/classes/index.ClockTime.html +32 -32
- package/docs/classes/index.ClockTimeTz.html +35 -35
- package/docs/classes/index.DateTime.html +86 -86
- package/docs/classes/index.Decorators.html +19 -19
- package/docs/classes/index.Dream.html +124 -124
- package/docs/classes/index.DreamApp.html +10 -10
- package/docs/classes/index.DreamTransaction.html +2 -2
- package/docs/classes/index.Env.html +2 -2
- package/docs/classes/index.Query.html +735 -73
- package/docs/classes/system.CliFileWriter.html +4 -4
- package/docs/classes/system.DreamBin.html +2 -2
- package/docs/classes/system.DreamCLI.html +7 -7
- package/docs/classes/system.DreamImporter.html +2 -2
- package/docs/classes/system.DreamLogos.html +2 -2
- package/docs/classes/system.DreamSerializerBuilder.html +11 -11
- package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
- package/docs/classes/system.PathHelpers.html +3 -3
- package/docs/classes/utils.Encrypt.html +3 -3
- package/docs/classes/utils.Range.html +2 -2
- package/docs/functions/db.closeAllDbConnections.html +1 -1
- package/docs/functions/db.dreamDbConnections.html +1 -1
- package/docs/functions/db.untypedDb.html +1 -1
- package/docs/functions/db.validateColumn.html +1 -1
- package/docs/functions/db.validateTable.html +1 -1
- package/docs/functions/errors.pgErrorType.html +1 -1
- package/docs/functions/index.DreamSerializer.html +1 -1
- package/docs/functions/index.ObjectSerializer.html +1 -1
- package/docs/functions/index.ReplicaSafe.html +1 -1
- package/docs/functions/index.STI.html +1 -1
- package/docs/functions/index.SoftDelete.html +1 -1
- package/docs/functions/utils.camelize.html +1 -1
- package/docs/functions/utils.capitalize.html +1 -1
- package/docs/functions/utils.cloneDeepSafe.html +1 -1
- package/docs/functions/utils.compact.html +1 -1
- package/docs/functions/utils.groupBy.html +1 -1
- package/docs/functions/utils.hyphenize.html +1 -1
- package/docs/functions/utils.intersection.html +1 -1
- package/docs/functions/utils.isEmpty.html +1 -1
- package/docs/functions/utils.normalizeUnicode.html +1 -1
- package/docs/functions/utils.pascalize.html +1 -1
- package/docs/functions/utils.percent.html +1 -1
- package/docs/functions/utils.range.html +1 -1
- package/docs/functions/utils.round.html +1 -1
- package/docs/functions/utils.sanitizeString.html +1 -1
- package/docs/functions/utils.snakeify.html +1 -1
- package/docs/functions/utils.sort.html +1 -1
- package/docs/functions/utils.sortBy.html +1 -1
- package/docs/functions/utils.sortObjectByKey.html +1 -1
- package/docs/functions/utils.sortObjectByValue.html +1 -1
- package/docs/functions/utils.uncapitalize.html +1 -1
- package/docs/functions/utils.uniq.html +1 -1
- package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
- package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
- package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
- package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
- package/docs/interfaces/types.BelongsToStatement.html +2 -2
- package/docs/interfaces/types.DecoratorContext.html +2 -2
- package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
- package/docs/interfaces/types.DreamAppOpts.html +2 -2
- package/docs/interfaces/types.DreamDbConfig.html +5 -5
- package/docs/interfaces/types.DurationObject.html +2 -2
- package/docs/interfaces/types.EncryptOptions.html +2 -2
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
- package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
- package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
- package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
- package/docs/types/openapi.OpenapiAllTypes.html +1 -1
- package/docs/types/openapi.OpenapiFormats.html +1 -1
- package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
- package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
- package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
- package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
- package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
- package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
- package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +2 -2
- package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +2 -2
- package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +2 -2
- package/docs/types/openapi.OpenapiSchemaExpressionRef.html +2 -2
- package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +2 -2
- package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
- package/docs/types/openapi.OpenapiSchemaNull.html +2 -2
- package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
- package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +2 -2
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +2 -2
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +2 -2
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +2 -2
- package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +2 -2
- package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
- package/docs/types/openapi.OpenapiSchemaString.html +1 -1
- package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
- package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
- package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
- package/docs/types/openapi.OpenapiTypeField.html +1 -1
- package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
- package/docs/types/types.CalendarDateDurationUnit.html +1 -1
- package/docs/types/types.CalendarDateObject.html +1 -1
- package/docs/types/types.Camelized.html +1 -1
- package/docs/types/types.ClockTimeObject.html +1 -1
- package/docs/types/types.DbConnectionType.html +1 -1
- package/docs/types/types.DbTypes.html +1 -1
- package/docs/types/types.DreamAssociationMetadata.html +1 -1
- package/docs/types/types.DreamAttributes.html +1 -1
- package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
- package/docs/types/types.DreamClassColumn.html +1 -1
- package/docs/types/types.DreamColumn.html +1 -1
- package/docs/types/types.DreamColumnNames.html +1 -1
- package/docs/types/types.DreamLogLevel.html +1 -1
- package/docs/types/types.DreamLogger.html +2 -2
- package/docs/types/types.DreamModelSerializerType.html +1 -1
- package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
- package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
- package/docs/types/types.DreamParamSafeAttributes.html +1 -1
- package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
- package/docs/types/types.DreamSerializable.html +1 -1
- package/docs/types/types.DreamSerializableArray.html +1 -1
- package/docs/types/types.DreamSerializerKey.html +1 -1
- package/docs/types/types.DreamSerializers.html +1 -1
- package/docs/types/types.DreamVirtualColumns.html +1 -1
- package/docs/types/types.DurationUnit.html +1 -1
- package/docs/types/types.EncryptAlgorithm.html +1 -1
- package/docs/types/types.HasManyStatement.html +1 -1
- package/docs/types/types.HasOneStatement.html +1 -1
- package/docs/types/types.Hyphenized.html +1 -1
- package/docs/types/types.Pascalized.html +1 -1
- package/docs/types/types.PrimaryKeyType.html +1 -1
- package/docs/types/types.RoundingPrecision.html +1 -1
- package/docs/types/types.SerializerCasing.html +1 -1
- package/docs/types/types.SimpleObjectSerializerType.html +1 -1
- package/docs/types/types.Snakeified.html +1 -1
- package/docs/types/types.StrictInterface.html +1 -1
- package/docs/types/types.UpdateableAssociationProperties.html +1 -1
- package/docs/types/types.UpdateableProperties.html +1 -1
- package/docs/types/types.ValidationType.html +1 -1
- package/docs/types/types.ViewModel.html +2 -2
- package/docs/types/types.ViewModelClass.html +1 -1
- package/docs/types/types.WeekdayName.html +1 -1
- package/docs/types/types.WhereStatementForDream.html +1 -1
- package/docs/types/types.WhereStatementForDreamClass.html +1 -1
- package/docs/variables/index.DreamConst.html +1 -1
- package/docs/variables/index.ops.html +1 -1
- package/docs/variables/openapi.openapiPrimitiveTypes.html +1 -1
- package/docs/variables/openapi.openapiShorthandPrimitiveTypes.html +1 -1
- package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
- package/docs/variables/system.primaryKeyTypes.html +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Query | @rvoh/dream</title><meta name="description" content="Documentation for @rvoh/dream"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@rvoh/dream</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/index.html">index</a></li><li><a href="" aria-current="page">Query</a></li></ul><h1>Class Query<DreamInstance, QueryTypeOpts></h1></div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="dreaminstance"><span class="tsd-kind-type-parameter">DreamInstance</span> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a></span></li><li><span id="querytypeopts"><span class="tsd-kind-type-parameter">QueryTypeOpts</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">QueryTypeOptions</span><span class="tsd-signature-symbol">></span> = <span class="tsd-signature-type">DefaultQueryTypeOptions</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></span></li></ul></section><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
1
|
+
<!DOCTYPE html><html class="default" lang="en" data-base="../"><head><meta charset="utf-8"/><meta http-equiv="x-ua-compatible" content="IE=edge"/><title>Query | @rvoh/dream</title><meta name="description" content="Documentation for @rvoh/dream"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="../assets/style.css"/><link rel="stylesheet" href="../assets/highlight.css"/><script defer src="../assets/main.js"></script><script async src="../assets/icons.js" id="tsd-icons-script"></script><script async src="../assets/search.js" id="tsd-search-script"></script><script async src="../assets/navigation.js" id="tsd-nav-script"></script><script async src="../assets/hierarchy.js" id="tsd-hierarchy-script"></script></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";document.body.style.display="none";setTimeout(() => window.app?app.showPage():document.body.style.removeProperty("display"),500)</script><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><a href="../index.html" class="title">@rvoh/dream</a><div id="tsd-toolbar-links"></div><button id="tsd-search-trigger" class="tsd-widget" aria-label="Search"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-search"></use></svg></button><dialog id="tsd-search" aria-label="Search"><input role="combobox" id="tsd-search-input" aria-controls="tsd-search-results" aria-autocomplete="list" aria-expanded="true" autocapitalize="off" autocomplete="off" placeholder="Search the docs" maxLength="100"/><ul role="listbox" id="tsd-search-results"></ul><div id="tsd-search-status" aria-live="polite" aria-atomic="true"><div>Preparing search index...</div></div></dialog><a href="#" class="tsd-widget menu" id="tsd-toolbar-menu-trigger" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></header><div class="container container-main"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb" aria-label="Breadcrumb"><li><a href="../modules/index.html">index</a></li><li><a href="" aria-current="page">Query</a></li></ul><h1>Class Query<DreamInstance, QueryTypeOpts></h1></div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="dreaminstance"><span class="tsd-kind-type-parameter">DreamInstance</span> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a></span></li><li><span id="querytypeopts"><span class="tsd-kind-type-parameter">QueryTypeOpts</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">QueryTypeOptions</span><span class="tsd-signature-symbol">></span> = <span class="tsd-signature-type">DefaultQueryTypeOptions</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></span></li></ul></section><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L113">src/dream/Query.ts:113</a></li></ul></aside><section class="tsd-panel-group tsd-index-group"><section class="tsd-panel tsd-index-panel"><details class="tsd-index-content tsd-accordion" open><summary class="tsd-accordion-summary tsd-index-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h5 class="tsd-index-heading uppercase">Index</h5></summary><div class="tsd-accordion-details"><section class="tsd-index-section"><h3 class="tsd-index-heading">Constructors</h3><div class="tsd-index-list"><a href="#constructor" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a>
|
|
2
2
|
</div></section><section class="tsd-index-section"><h3 class="tsd-index-heading">Properties</h3><div class="tsd-index-list"><a href="#connectionoverride" class="tsd-index-link tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>connection<wbr/>Override</span></a>
|
|
3
3
|
<a href="#dreamclass" class="tsd-index-link tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>dream<wbr/>Class</span></a>
|
|
4
4
|
<a href="#dreaminstance-1" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>dream<wbr/>Instance</span></a>
|
|
@@ -64,16 +64,16 @@
|
|
|
64
64
|
<a href="#whereany" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>where<wbr/>Any</span></a>
|
|
65
65
|
<a href="#wherenot" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>where<wbr/>Not</span></a>
|
|
66
66
|
<a href="#dbdriverclass" class="tsd-index-link"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>db<wbr/>Driver<wbr/>Class</span></a>
|
|
67
|
-
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Constructors</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="constructor"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="constructorquery"><span class="tsd-signature-keyword">new</span> <span class="tsd-kind-constructor-signature">Query</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#constructorquerydreaminstance">DreamInstance</a> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#constructorqueryquerytypeopts">QueryTypeOpts</a> <span class="tsd-signature-keyword">extends</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">QueryTypeOptions</span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">dreamInstance</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">opts</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">QueryOpts</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#constructorquery" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="constructorquerydreaminstance"><span class="tsd-kind-type-parameter">DreamInstance</span> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a></span></li><li><span id="constructorqueryquerytypeopts"><span class="tsd-kind-type-parameter">QueryTypeOpts</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">QueryTypeOptions</span><span class="tsd-signature-symbol">></span> = <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">dreamInstance</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a></span></li><li><span><span class="tsd-kind-parameter">opts</span>: <span class="tsd-signature-type">QueryOpts</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol"> = {}</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/276ab87aae35de8dce4d5a4e3052373f512d2717/src/dream/Query.ts#L370">src/dream/Query.ts:370</a></li></ul></aside></div></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Properties</h2></summary><section><section class="tsd-panel tsd-member tsd-is-protected"><h3 class="tsd-anchor-link" id="connectionoverride"><code class="tsd-tag">Protected</code><span>connection<wbr/>Override</span><a href="#connectionoverride" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">connectionOverride</span><span class="tsd-signature-symbol">:</span> <a href="../types/types.DbConnectionType.html" class="tsd-signature-type tsd-kind-type-alias">DbConnectionType</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">undefined</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/276ab87aae35de8dce4d5a4e3052373f512d2717/src/dream/Query.ts#L361">src/dream/Query.ts:361</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-protected"><h3 class="tsd-anchor-link" id="dreamclass"><code class="tsd-tag">Protected</code> <code class="tsd-tag">Readonly</code><span>dream<wbr/>Class</span><a href="#dreamclass" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">dreamClass</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">DreamConstructorType</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/276ab87aae35de8dce4d5a4e3052373f512d2717/src/dream/Query.ts#L359">src/dream/Query.ts:359</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="dreaminstance-1"><code class="tsd-tag">Readonly</code><span>dream<wbr/>Instance</span><a href="#dreaminstance-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">dreamInstance</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/276ab87aae35de8dce4d5a4e3052373f512d2717/src/dream/Query.ts#L360">src/dream/Query.ts:360</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="dreamtransaction"><code class="tsd-tag">Internal</code><span>dream<wbr/>Transaction</span><a href="#dreamtransaction" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">dreamTransaction</span><span class="tsd-signature-symbol">:</span> <a href="index.DreamTransaction.html" class="tsd-signature-type tsd-kind-class">DreamTransaction</a><span class="tsd-signature-symbol"><</span><a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> = null</span></div><div class="tsd-comment tsd-typography"><p>stores the dream transaction applied to the
|
|
67
|
+
</div></section></div></details></section></section><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Constructors</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="constructor"><span>constructor</span><a href="#constructor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="constructorquery"><span class="tsd-signature-keyword">new</span> <span class="tsd-kind-constructor-signature">Query</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#constructorquerydreaminstance">DreamInstance</a> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#constructorqueryquerytypeopts">QueryTypeOpts</a> <span class="tsd-signature-keyword">extends</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">QueryTypeOptions</span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">dreamInstance</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">opts</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">QueryOpts</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#constructorquery" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="constructorquerydreaminstance"><span class="tsd-kind-type-parameter">DreamInstance</span> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a></span></li><li><span id="constructorqueryquerytypeopts"><span class="tsd-kind-type-parameter">QueryTypeOpts</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">QueryTypeOptions</span><span class="tsd-signature-symbol">></span> = <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">dreamInstance</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a></span></li><li><span><span class="tsd-kind-parameter">opts</span>: <span class="tsd-signature-type">QueryOpts</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol"> = {}</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L374">src/dream/Query.ts:374</a></li></ul></aside></div></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Properties</h2></summary><section><section class="tsd-panel tsd-member tsd-is-protected"><h3 class="tsd-anchor-link" id="connectionoverride"><code class="tsd-tag">Protected</code><span>connection<wbr/>Override</span><a href="#connectionoverride" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">connectionOverride</span><span class="tsd-signature-symbol">:</span> <a href="../types/types.DbConnectionType.html" class="tsd-signature-type tsd-kind-type-alias">DbConnectionType</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">undefined</span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L365">src/dream/Query.ts:365</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-protected"><h3 class="tsd-anchor-link" id="dreamclass"><code class="tsd-tag">Protected</code> <code class="tsd-tag">Readonly</code><span>dream<wbr/>Class</span><a href="#dreamclass" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">dreamClass</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">DreamConstructorType</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L363">src/dream/Query.ts:363</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="dreaminstance-1"><code class="tsd-tag">Readonly</code><span>dream<wbr/>Instance</span><a href="#dreaminstance-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">dreamInstance</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L364">src/dream/Query.ts:364</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="dreamtransaction"><code class="tsd-tag">Internal</code><span>dream<wbr/>Transaction</span><a href="#dreamtransaction" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">dreamTransaction</span><span class="tsd-signature-symbol">:</span> <a href="index.DreamTransaction.html" class="tsd-signature-type tsd-kind-class">DreamTransaction</a><span class="tsd-signature-symbol"><</span><a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol"> = null</span></div><div class="tsd-comment tsd-typography"><p>stores the dream transaction applied to the
|
|
68
68
|
current Query instance</p>
|
|
69
|
-
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
70
|
-
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
71
|
-
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
69
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L147">src/dream/Query.ts:147</a></li></ul></aside></section><section class="tsd-panel tsd-member tsd-is-protected"><h3 class="tsd-anchor-link" id="innerjoindreamclasses"><code class="tsd-tag">Protected</code> <code class="tsd-tag">Readonly</code> <code class="tsd-tag">Internal</code><span>inner<wbr/>Join<wbr/>Dream<wbr/>Classes</span><a href="#innerjoindreamclasses" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">innerJoinDreamClasses</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-keyword">typeof</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol"> = ...</span></div><div class="tsd-comment tsd-typography"><p>stores the Dream models joined in this Query instance</p>
|
|
70
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L372">src/dream/Query.ts:372</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="querytypeopts-1"><code class="tsd-tag">Internal</code><span>query<wbr/>Type<wbr/>Opts</span><a href="#querytypeopts-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">queryTypeOpts</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a></div><div class="tsd-comment tsd-typography"><p>purely for typing</p>
|
|
71
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L139">src/dream/Query.ts:139</a></li></ul></aside></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="batch_sizes"><code class="tsd-tag">Static</code> <code class="tsd-tag">Readonly</code> <code class="tsd-tag">Internal</code><span>BATCH_<wbr/>SIZES</span><a href="#batch_sizes" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><div class="tsd-signature"><span class="tsd-kind-property">BATCH_SIZES</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">FIND_EACH</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">LOCKED_DESTROY</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">LOCKED_UPDATE</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">PLUCK_EACH</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">PLUCK_EACH_THROUGH</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/><span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol"> = ...</span></div><div class="tsd-comment tsd-typography"><p>stores the default batch sizes for various
|
|
72
72
|
provided batching methods</p>
|
|
73
|
-
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
73
|
+
</div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L123">src/dream/Query.ts:123</a></li></ul></aside></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Accessors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Accessors</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="connectionname"><span>connection<wbr/>Name</span><a href="#connectionname" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li><div class="tsd-signature" id="connectionnameconnectionname"><span class="tsd-signature-keyword">get</span> <span class="tsd-kind-get-signature">connectionName</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">any</span></div><div class="tsd-description"><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">any</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2125">src/dream/Query.ts:2125</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="isdreamquery"><span>is<wbr/>Dream<wbr/>Query</span><a href="#isdreamquery" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li><div class="tsd-signature" id="isdreamqueryisdreamquery"><span class="tsd-signature-keyword">get</span> <span class="tsd-kind-get-signature">isDreamQuery</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns true. Useful for distinguishing Query instances
|
|
74
74
|
from other objects.</p>
|
|
75
75
|
</div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">boolean</span></h4><p>true</p>
|
|
76
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
76
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L416">src/dream/Query.ts:416</a></li></ul></aside></div></li></ul></section></section></details><details class="tsd-panel-group tsd-member-group tsd-accordion" open><summary class="tsd-accordion-summary" data-key="section-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h2>Methods</h2></summary><section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="all"><span>all</span><a href="#all" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="all-1"><span class="tsd-kind-call-signature">all</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">columns</span><span class="tsd-signature-symbol">?:</span> (<br/> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-type">string</span><br/> )<span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">></span><a href="#all-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Retrieves an array containing all records matching the Query.
|
|
77
77
|
Be careful using this, since it will attempt to pull every
|
|
78
78
|
record into memory at once. When querying might return a large
|
|
79
79
|
number of records, consider using <code>.findEach</code>, which will pull
|
|
@@ -84,14 +84,14 @@ the records in batches.</p>
|
|
|
84
84
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">columns</span><span class="tsd-signature-symbol">?:</span> (<br/> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-type">string</span><br/> )<span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">;</span><br/><span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol"> = {}</span></span><div class="tsd-comment tsd-typography"><p>Query options</p>
|
|
85
85
|
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">columns</span><span class="tsd-signature-symbol">?: </span>(<br/> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-type">string</span><br/>)<span class="tsd-signature-symbol">[]</span></h5><div class="tsd-comment tsd-typography"><p>Array of column names to select. The primary key is always included automatically.</p>
|
|
86
86
|
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">></span></h4><p>an array of dreams</p>
|
|
87
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
87
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2107">src/dream/Query.ts:2107</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="avg"><span>avg</span><a href="#avg" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="avg-1"><span class="tsd-kind-call-signature">avg</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgdb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgcolumnname">ColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgreturntype">ReturnType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">columnName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgcolumnname">ColumnName</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#avgreturntype">ReturnType</a><span class="tsd-signature-symbol">></span><a href="#avg-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Retrieves the average value of the specified column
|
|
88
88
|
for this Query</p>
|
|
89
89
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">Game</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">avg</span><span class="hl-1">(</span><span class="hl-6">'score'</span><span class="hl-1">)</span><br/><span class="hl-7">// 1</span>
|
|
90
90
|
</code><button type="button">Copy</button></pre>
|
|
91
91
|
|
|
92
92
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="avgq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span id="avgdb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="avgcolumnname"><span class="tsd-kind-type-parameter">ColumnName</span></span></li><li><span id="avgreturntype"><span class="tsd-kind-type-parameter">ReturnType</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">columnName</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgcolumnname">ColumnName</a></span><div class="tsd-comment tsd-typography"><p>a column name on the model</p>
|
|
93
93
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#avgreturntype">ReturnType</a><span class="tsd-signature-symbol">></span></h4><p>the average of the values of the specified column for this Query</p>
|
|
94
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
94
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1903">src/dream/Query.ts:1903</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="avgby"><span>avg<wbr/>By</span><a href="#avgby" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="avgby-1"><span class="tsd-kind-call-signature">avgBy</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbyq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbydb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbygroupcolumnname">GroupColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbyaggregatedcolumnname">AggregatedColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbygroupkey">GroupKey</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbyaggregatedtype">AggregatedType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">groupColumn</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbygroupcolumnname">GroupColumnName</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">aggregatedColumn</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbyaggregatedcolumnname">AggregatedColumnName</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbygroupkey">GroupKey</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbyaggregatedtype">AggregatedType</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span><a href="#avgby-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Retrieves the average of the specified column within each group, keyed by
|
|
95
95
|
the value of the provided group column (a SQL <code>GROUP BY</code>).</p>
|
|
96
96
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">CompositionAsset</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">avgBy</span><span class="hl-1">(</span><span class="hl-6">'name'</span><span class="hl-1">, </span><span class="hl-6">'score'</span><span class="hl-1">)</span><br/><span class="hl-7">// Map(2) { 'primary' => 5, 'secondary' => 4 }</span>
|
|
97
97
|
</code><button type="button">Copy</button></pre>
|
|
@@ -107,23 +107,23 @@ are grouped under a real <code>null</code> key; a group whose aggregated values
|
|
|
107
107
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="avgbyq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span id="avgbydb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="avgbygroupcolumnname"><span class="tsd-kind-type-parameter">GroupColumnName</span></span></li><li><span id="avgbyaggregatedcolumnname"><span class="tsd-kind-type-parameter">AggregatedColumnName</span></span></li><li><span id="avgbygroupkey"><span class="tsd-kind-type-parameter">GroupKey</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="avgbyaggregatedtype"><span class="tsd-kind-type-parameter">AggregatedType</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">groupColumn</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbygroupcolumnname">GroupColumnName</a></span><div class="tsd-comment tsd-typography"><p>the column to group by (base or joined-association-namespaced)</p>
|
|
108
108
|
</div></li><li><span><span class="tsd-kind-parameter">aggregatedColumn</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbyaggregatedcolumnname">AggregatedColumnName</a></span><div class="tsd-comment tsd-typography"><p>the column to average within each group</p>
|
|
109
109
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbygroupkey">GroupKey</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#avgbyaggregatedtype">AggregatedType</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span></h4><p>A Map from each present group value to the average of the aggregated column in that group</p>
|
|
110
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
110
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1940">src/dream/Query.ts:1940</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="clone"><span>clone</span><a href="#clone" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="clone-1"><span class="tsd-kind-call-signature">clone</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#cloneq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#cloneq">Q</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">opts</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">QueryOpts</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#cloneq">Q</a><a href="#clone-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><code class="tsd-tag">Internal</code><div class="tsd-comment tsd-typography"><p>Returns a cloned version of the Query</p>
|
|
111
111
|
<pre><code class="ts"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">clonedQuery</span><span class="hl-1"> = </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">clone</span><span class="hl-1">()</span>
|
|
112
112
|
</code><button type="button">Copy</button></pre>
|
|
113
113
|
|
|
114
114
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="cloneq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#cloneq">Q</a></span></li><li><span><span class="tsd-kind-parameter">opts</span>: <span class="tsd-signature-type">QueryOpts</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol"> = {}</span></span><div class="tsd-comment tsd-typography"><p>Statements to override when cloning the Query</p>
|
|
115
115
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="#cloneq">Q</a></h4><p>A cloned Query with the provided overrides clause applied</p>
|
|
116
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
116
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L432">src/dream/Query.ts:432</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="connection"><span>connection</span><a href="#connection" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="connection-1"><span class="tsd-kind-call-signature">connection</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">connection</span><span class="tsd-signature-symbol">:</span> <a href="../types/types.DbConnectionType.html" class="tsd-signature-type tsd-kind-type-alias">DbConnectionType</a><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#connection-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Forces use of a database connection (e.g. 'primary') during the query.</p>
|
|
117
117
|
<p>NOTE: all queries within a transaction always use the 'primary' replica, so
|
|
118
118
|
explicitly setting connection within a transaction has no effect.</p>
|
|
119
119
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">connection</span>: <a href="../types/types.DbConnectionType.html" class="tsd-signature-type tsd-kind-type-alias">DbConnectionType</a></span><div class="tsd-comment tsd-typography"><p>The connection you wish to access ('primary' or 'replica')</p>
|
|
120
120
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><p>A Query with the requested connection</p>
|
|
121
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
121
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2438">src/dream/Query.ts:2438</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="count"><span>count</span><a href="#count" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="count-1"><span class="tsd-kind-call-signature">count</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span><a href="#count-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Retrieves the number of records matching the Query</p>
|
|
122
122
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">count</span><span class="hl-1">()</span><br/><span class="hl-7">// 42</span><br/><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-4">ops</span><span class="hl-1">.</span><span class="hl-5">ilike</span><span class="hl-1">(</span><span class="hl-6">'%gmail.com'</span><span class="hl-1">) }).</span><span class="hl-5">count</span><span class="hl-1">()</span><br/><span class="hl-7">// 15</span>
|
|
123
123
|
</code><button type="button">Copy</button></pre>
|
|
124
124
|
|
|
125
125
|
</div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span></h4><p>The number of records matching the Query</p>
|
|
126
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
126
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1579">src/dream/Query.ts:1579</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="countby"><span>count<wbr/>By</span><a href="#countby" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="countby-1"><span class="tsd-kind-call-signature">countBy</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#countbyq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#countbydb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#countbygroupcolumnname">GroupColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#countbygroupkey">GroupKey</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">groupColumn</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#countbygroupcolumnname">GroupColumnName</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#countbygroupkey">GroupKey</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span><a href="#countby-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Retrieves the number of records in each group, keyed by the
|
|
127
127
|
value of the provided group column (a SQL <code>GROUP BY</code>).</p>
|
|
128
128
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">countBy</span><span class="hl-1">(</span><span class="hl-6">'name'</span><span class="hl-1">)</span><br/><span class="hl-7">// Map(2) { 'fred' => 2, 'zed' => 1 }</span><br/><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-4">ops</span><span class="hl-1">.</span><span class="hl-5">ilike</span><span class="hl-1">(</span><span class="hl-6">'%gmail.com'</span><span class="hl-1">) }).</span><span class="hl-5">countBy</span><span class="hl-1">(</span><span class="hl-6">'name'</span><span class="hl-1">)</span><br/><span class="hl-7">// Map(1) { 'fred' => 3 }</span>
|
|
129
129
|
</code><button type="button">Copy</button></pre>
|
|
@@ -141,7 +141,7 @@ group column is nullable, records with a <code>null</code> value are grouped und
|
|
|
141
141
|
|
|
142
142
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="countbyq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span id="countbydb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="countbygroupcolumnname"><span class="tsd-kind-type-parameter">GroupColumnName</span></span></li><li><span id="countbygroupkey"><span class="tsd-kind-type-parameter">GroupKey</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">groupColumn</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#countbygroupcolumnname">GroupColumnName</a></span><div class="tsd-comment tsd-typography"><p>the column to group by (base or joined-association-namespaced)</p>
|
|
143
143
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#countbygroupkey">GroupKey</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span></h4><p>A Map from each present group value to the number of records in that group</p>
|
|
144
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
144
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1613">src/dream/Query.ts:1613</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="cursorpaginate"><span>cursor<wbr/>Paginate</span><a href="#cursorpaginate" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="cursorpaginate-1"><span class="tsd-kind-call-signature">cursorPaginate</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#cursorpaginateq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#cursorpaginateincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#cursorpaginateq">Q</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">opts</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#cursorpaginateincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"scrollPaginate is incompatible with limit, offset, and leftJoinPreload"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">CursorPaginatedDreamQueryOptions</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">CursorPaginatedDreamQueryResult</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span><a href="#cursorpaginate-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Paginates the results of your query using cursor-based pagination,
|
|
145
145
|
accepting a pageSize and cursor argument. This method
|
|
146
146
|
provides better performance for large datasets by using cursor-based
|
|
147
147
|
pagination instead of offset-based pagination.</p>
|
|
@@ -153,7 +153,7 @@ then the implicit primary key ordering will be omitted.</p>
|
|
|
153
153
|
|
|
154
154
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="cursorpaginateq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span></li><li><span id="cursorpaginateincompatible"><span class="tsd-kind-type-parameter">Incompatible</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#cursorpaginateq">Q</a></span></li><li><span><span class="tsd-kind-parameter">opts</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#cursorpaginateincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"scrollPaginate is incompatible with limit, offset, and leftJoinPreload"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">CursorPaginatedDreamQueryOptions</span></span><div class="tsd-comment tsd-typography"><p>cursor pagination options</p>
|
|
155
155
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">CursorPaginatedDreamQueryResult</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span></h4><p>results.cursor - identifier for the next page, or null if no more pages</p>
|
|
156
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
156
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2295">src/dream/Query.ts:2295</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="dbdriverinstance"><span>db<wbr/>Driver<wbr/>Instance</span><a href="#dbdriverinstance" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="dbdriverinstance-1"><span class="tsd-kind-call-signature">dbDriverInstance</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">query</span><span class="tsd-signature-symbol">?:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="db.QueryDriverBase.html" class="tsd-signature-type tsd-kind-class">QueryDriverBase</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><a href="#dbdriverinstance-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">query</span>: <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol"> = ...</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="db.QueryDriverBase.html" class="tsd-signature-type tsd-kind-class">QueryDriverBase</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2120">src/dream/Query.ts:2120</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="delete"><span>delete</span><a href="#delete" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="delete-1"><span class="tsd-kind-call-signature">delete</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span><a href="#delete-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Deletes all records matching query using a single
|
|
157
157
|
database query, but does not call underlying callbacks.
|
|
158
158
|
Ignores association dependent destroy declarations,
|
|
159
159
|
though cascading may still happen at the database level.</p>
|
|
@@ -163,7 +163,7 @@ use <a href="#destroy" class="tsd-kind-method">Query.destroy</a> instead.</p>
|
|
|
163
163
|
</code><button type="button">Copy</button></pre>
|
|
164
164
|
|
|
165
165
|
</div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span></h4><p>The number of records that were removed</p>
|
|
166
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
166
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2961">src/dream/Query.ts:2961</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="destroy"><span>destroy</span><a href="#destroy" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="destroy-1"><span class="tsd-kind-call-signature">destroy</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">cascade</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span><a href="#destroy-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Destroys all records matching the Query,
|
|
167
167
|
calling model hooks and cascading destroy
|
|
168
168
|
to associations with <code>dependent: 'destroy'</code>,
|
|
169
169
|
and returns the number of records that
|
|
@@ -240,19 +240,26 @@ long-running writer on the other side stalls the run indefinitely and, at
|
|
|
240
240
|
scale, ties up connections. If that is a risk in your application, set a
|
|
241
241
|
<code>lock_timeout</code> on the connection so a stuck batch fails instead of
|
|
242
242
|
hanging.</li>
|
|
243
|
+
<li><strong>A <code>limit</code> or <code>offset</code> on the Query is incompatible with <code>destroy</code> on
|
|
244
|
+
every path.</strong> The batches — locked and unlocked alike — re-apply the
|
|
245
|
+
Query's conditions to each window, where a limit or offset would skip
|
|
246
|
+
or truncate rows inside every window instead of bounding the run as a
|
|
247
|
+
whole, so <code>destroy</code> throws rather than silently corrupting the
|
|
248
|
+
windows.</li>
|
|
243
249
|
<li><strong>If you are destroying a large set and do not need compare-and-set, do
|
|
244
250
|
not pass <code>lock</code>.</strong> Plain <code>destroy()</code> (hooks and cascade, no locking) or
|
|
245
251
|
<a href="#delete" class="tsd-kind-method">delete</a> (a single statement, no hooks or cascade)
|
|
246
252
|
are the right tools for bulk removal.</li>
|
|
247
253
|
</ul>
|
|
248
|
-
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">
|
|
254
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">cascade</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol"> = {}</span></span><div class="tsd-comment tsd-typography"><p>Options for destroying the instance</p>
|
|
249
255
|
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><p>The number of records to process per batch. Must be a positive integer. Defaults to 10 when <code>lock</code> is true, and to 1000 otherwise</p>
|
|
250
256
|
</div></li><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">cascade</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>If false, skips destroying associations marked <code>dependent: 'destroy'</code>. Defaults to true</p>
|
|
251
257
|
</div></li><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>If true, each batch is re-selected with an exclusive row lock inside its own transaction before being destroyed, making the destroy a compare-and-set. Defaults to false</p>
|
|
252
258
|
</div></li><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>If true, skips applying model hooks during the destroy operation. Defaults to false</p>
|
|
253
259
|
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span></h4><p>The number of records that were removed</p>
|
|
254
260
|
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws">Throws<a href="#throws" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>InvalidBatchSize if <code>batchSize</code> is not a positive integer</p>
|
|
255
|
-
</div
|
|
261
|
+
</div><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-1">Throws<a href="#throws-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>BatchingIncompatibleWithLimitOrOffset if the query carries a <code>limit</code> or <code>offset</code></p>
|
|
262
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2672">src/dream/Query.ts:2672</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="distinct"><span>distinct</span><a href="#distinct" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="distinct-1"><span class="tsd-kind-call-signature">distinct</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">column</span><span class="tsd-signature-symbol">?:</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">boolean</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">TableColumnNames</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#distinct-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns new Query with distinct clause applied.
|
|
256
263
|
If no column is specified, applies distinct to the primary key.
|
|
257
264
|
Pass true to apply distinct to primary key, false to disable distinct.</p>
|
|
258
265
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">distinct</span><span class="hl-1">(</span><span class="hl-6">'name'</span><span class="hl-1">).</span><span class="hl-5">pluck</span><span class="hl-1">(</span><span class="hl-6">'name'</span><span class="hl-1">)</span><br/><span class="hl-7">// Returns unique names</span><br/><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">distinct</span><span class="hl-1">(</span><span class="hl-0">true</span><span class="hl-1">).</span><span class="hl-5">pluck</span><span class="hl-1">(</span><span class="hl-6">'id'</span><span class="hl-1">)</span><br/><span class="hl-7">// Returns unique primary keys</span><br/><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">distinct</span><span class="hl-1">(</span><span class="hl-0">false</span><span class="hl-1">).</span><span class="hl-5">pluck</span><span class="hl-1">(</span><span class="hl-6">'name'</span><span class="hl-1">)</span><br/><span class="hl-7">// Disables distinct, returns all names including duplicates</span>
|
|
@@ -260,19 +267,19 @@ Pass true to apply distinct to primary key, false to disable distinct.</p>
|
|
|
260
267
|
|
|
261
268
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">column</span>: <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">TableColumnNames</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol"> = true</span></span><div class="tsd-comment tsd-typography"><p>The column name to apply distinct to, <code>true</code> to enable distinct on primary key, or <code>false</code> to disable a previously applied distinct call</p>
|
|
262
269
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><p>A cloned Query with the distinct clause applied</p>
|
|
263
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
270
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1646">src/dream/Query.ts:1646</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="exists"><span>exists</span><a href="#exists" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="exists-1"><span class="tsd-kind-call-signature">exists</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">></span><a href="#exists-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns true if a record exists for the given Query, false otherwise.</p>
|
|
264
271
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">exists</span><span class="hl-1">()</span><br/><span class="hl-7">// false</span><br/><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">create</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-6">'how@yadoin'</span><span class="hl-1"> })</span><br/><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">exists</span><span class="hl-1">()</span><br/><span class="hl-7">// true</span><br/><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-6">'nonexistent@example.com'</span><span class="hl-1"> }).</span><span class="hl-5">exists</span><span class="hl-1">()</span><br/><span class="hl-7">// false</span>
|
|
265
272
|
</code><button type="button">Copy</button></pre>
|
|
266
273
|
|
|
267
274
|
</div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">></span></h4><p>boolean - true if any records match the query, false otherwise</p>
|
|
268
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
275
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2465">src/dream/Query.ts:2465</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="find"><span>find</span><a href="#find" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="find-1"><span class="tsd-kind-call-signature">find</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">primaryKey</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">PrimaryKeyForFind</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">></span><a href="#find-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Finds a record matching the Query with the
|
|
269
276
|
specified primary key. Returns null if not found.</p>
|
|
270
277
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">find</span><span class="hl-1">(</span><span class="hl-8">123</span><span class="hl-1">)</span><br/><span class="hl-7">// User{id: 123}</span><br/><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">find</span><span class="hl-1">(</span><span class="hl-0">null</span><span class="hl-1">)</span><br/><span class="hl-7">// null</span><br/><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">find</span><span class="hl-1">(</span><span class="hl-0">undefined</span><span class="hl-1">)</span><br/><span class="hl-7">// null</span>
|
|
271
278
|
</code><button type="button">Copy</button></pre>
|
|
272
279
|
|
|
273
280
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">primaryKey</span>: <span class="tsd-signature-type">PrimaryKeyForFind</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></span><div class="tsd-comment tsd-typography"><p>The primary key of the record to look up.</p>
|
|
274
281
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">></span></h4><p>Either the found record, or else null</p>
|
|
275
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
282
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L509">src/dream/Query.ts:509</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="findby"><span>find<wbr/>By</span><a href="#findby" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="findby-1"><span class="tsd-kind-call-signature">findBy</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">whereStatement</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">WhereStatement</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">></span><a href="#findby-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Finds a record matching the Query and the
|
|
276
283
|
specified where statement. If not found, null
|
|
277
284
|
is returned.</p>
|
|
278
285
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">findBy</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-6">'how@yadoin'</span><span class="hl-1"> })</span><br/><span class="hl-7">// User{email: 'how@yadoin'}</span>
|
|
@@ -280,7 +287,7 @@ is returned.</p>
|
|
|
280
287
|
|
|
281
288
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">whereStatement</span>: <span class="tsd-signature-type">WhereStatement</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></span><div class="tsd-comment tsd-typography"><p>The where statement used to locate the record</p>
|
|
282
289
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">></span></h4><p>Either the first record found matching the attributes, or else null</p>
|
|
283
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
290
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L549">src/dream/Query.ts:549</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="findeach"><span>find<wbr/>Each</span><a href="#findeach" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="findeach-1"><span class="tsd-kind-call-signature">findEach</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">cb</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">instance</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=></span> <span class="tsd-signature-type">void</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">__namedParameters</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span><a href="#findeach-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Finds all records matching the Query in batches,
|
|
284
291
|
and then calls the provided callback for each found record.
|
|
285
292
|
Once all records have been passed for a given batch, the next set of
|
|
286
293
|
records will be fetched and passed to your callback, until all
|
|
@@ -302,11 +309,16 @@ partway through the iteration could be skipped entirely or visited twice.
|
|
|
302
309
|
because a paginated UI tolerates that anomaly; a full traversal cannot.)</p>
|
|
303
310
|
<p>If you need records processed in a particular order, load them with a
|
|
304
311
|
regular ordered query instead of <code>findEach</code>.</p>
|
|
312
|
+
<p>A <code>limit</code> or <code>offset</code> on the Query cannot compose with the batch windows
|
|
313
|
+
— each batch re-applies the Query's conditions, so the limit would be
|
|
314
|
+
silently replaced by <code>batchSize</code> and the offset re-applied to every
|
|
315
|
+
window — so a limit- or offset-carrying Query throws at runtime.</p>
|
|
305
316
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span><span class="tsd-kind-parameter">cb</span>: <span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">instance</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=></span> <span class="tsd-signature-type">void</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></span><div class="tsd-comment tsd-typography"><p>The callback to call for each found record</p>
|
|
306
317
|
</div></li><li><span><span class="tsd-kind-parameter">__namedParameters</span>: <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol"> = {}</span></span><div class="tsd-comment tsd-typography"><p>Options for batch processing</p>
|
|
307
318
|
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><p>The batch size you wish to collect records in. If not provided, it will default to 1000</p>
|
|
308
319
|
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><p>void</p>
|
|
309
|
-
<
|
|
320
|
+
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-2">Throws<a href="#throws-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>BatchingIncompatibleWithLimitOrOffset if the query carries a <code>limit</code> or <code>offset</code></p>
|
|
321
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L615">src/dream/Query.ts:615</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="findorfail"><span>find<wbr/>Or<wbr/>Fail</span><a href="#findorfail" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="findorfail-1"><span class="tsd-kind-call-signature">findOrFail</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">primaryKey</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">PrimaryKeyForFind</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><a href="#findorfail-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Finds a record matching the Query with the
|
|
310
322
|
specified primary key. If not found, an exception
|
|
311
323
|
is raised.</p>
|
|
312
324
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">findOrFail</span><span class="hl-1">(</span><span class="hl-8">123</span><span class="hl-1">)</span><br/><span class="hl-7">// User{id: 123}</span>
|
|
@@ -314,7 +326,7 @@ is raised.</p>
|
|
|
314
326
|
|
|
315
327
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">primaryKey</span>: <span class="tsd-signature-type">PrimaryKeyForFind</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></span><div class="tsd-comment tsd-typography"><p>The primary key of the record to look up</p>
|
|
316
328
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></h4><p>The found record</p>
|
|
317
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
329
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L530">src/dream/Query.ts:530</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="findorfailby"><span>find<wbr/>Or<wbr/>Fail<wbr/>By</span><a href="#findorfailby" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="findorfailby-1"><span class="tsd-kind-call-signature">findOrFailBy</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">whereStatement</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">WhereStatement</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><a href="#findorfailby-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Finds a record matching the Query and the
|
|
318
330
|
specified where statement. If not found, an exception
|
|
319
331
|
is raised.</p>
|
|
320
332
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">findOrFailBy</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-6">'how@yadoin'</span><span class="hl-1"> })</span><br/><span class="hl-7">// User{email: 'how@yadoin'}</span>
|
|
@@ -322,7 +334,7 @@ is raised.</p>
|
|
|
322
334
|
|
|
323
335
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">whereStatement</span>: <span class="tsd-signature-type">WhereStatement</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></span><div class="tsd-comment tsd-typography"><p>The where statement used to locate the record</p>
|
|
324
336
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></h4><p>The first record found matching the attributes</p>
|
|
325
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
337
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L566">src/dream/Query.ts:566</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="first"><span>first</span><a href="#first" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="first-1"><span class="tsd-kind-call-signature">first</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">></span><a href="#first-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns the first record in the database
|
|
326
338
|
matching the Query. If the Query is not
|
|
327
339
|
ordered, it will automatically order
|
|
328
340
|
by primary key.</p>
|
|
@@ -330,7 +342,7 @@ by primary key.</p>
|
|
|
330
342
|
</code><button type="button">Copy</button></pre>
|
|
331
343
|
|
|
332
344
|
</div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">></span></h4><p>First record in the database, or null if no record exists</p>
|
|
333
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
345
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2488">src/dream/Query.ts:2488</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="firstorfail"><span>first<wbr/>Or<wbr/>Fail</span><a href="#firstorfail" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="firstorfail-1"><span class="tsd-kind-call-signature">firstOrFail</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><a href="#firstorfail-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns the first record in the database
|
|
334
346
|
matching the Query. If the Query is not
|
|
335
347
|
ordered, it will automatically order
|
|
336
348
|
by primary key. If no record is found,
|
|
@@ -339,15 +351,15 @@ an exception is raised.</p>
|
|
|
339
351
|
</code><button type="button">Copy</button></pre>
|
|
340
352
|
|
|
341
353
|
</div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></h4><p>First record in the database</p>
|
|
342
|
-
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-
|
|
343
|
-
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/276ab87aae35de8dce4d5a4e3052373f512d2717/src/dream/Query.ts#L2472">src/dream/Query.ts:2472</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="innerjoin"><span>inner<wbr/>Join</span><a href="#innerjoin" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="innerjoin-1"><span class="tsd-kind-call-signature">innerJoin</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoindb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinschema">Schema</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjointablename">TableName</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinarr">Arr</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinlastarg">LastArg</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-type">JoinedAssociationsTypeFromAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoindb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjointablename">TableName</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span><br/> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span> <span class="tsd-signature-symbol">=</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinretquery">RetQuery</a> <span class="tsd-signature-symbol">=</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLeftJoinPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPaginate"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociations">JoinedAssociations</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinretquery">RetQuery</a><a href="#innerjoin-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns a new Query instance, with the provided
|
|
354
|
+
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-3">Throws<a href="#throws-3" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>RecordNotFound if no record exists</p>
|
|
355
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2511">src/dream/Query.ts:2511</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="innerjoin"><span>inner<wbr/>Join</span><a href="#innerjoin" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="innerjoin-1"><span class="tsd-kind-call-signature">innerJoin</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoindb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinschema">Schema</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjointablename">TableName</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinarr">Arr</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinlastarg">LastArg</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-type">JoinedAssociationsTypeFromAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoindb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjointablename">TableName</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span><br/> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span> <span class="tsd-signature-symbol">=</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinretquery">RetQuery</a> <span class="tsd-signature-symbol">=</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLeftJoinPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPaginate"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociations">JoinedAssociations</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinretquery">RetQuery</a><a href="#innerjoin-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns a new Query instance, with the provided
|
|
344
356
|
joins statement attached</p>
|
|
345
357
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">innerJoin</span><span class="hl-1">(</span><span class="hl-6">'posts'</span><span class="hl-1">).</span><span class="hl-5">first</span><span class="hl-1">()</span>
|
|
346
358
|
</code><button type="button">Copy</button></pre>
|
|
347
359
|
|
|
348
360
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="innerjoindb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="innerjoinschema"><span class="tsd-kind-type-parameter">Schema</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="innerjointablename"><span class="tsd-kind-type-parameter">TableName</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span></span></li><li><span id="innerjoinarr"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">Arr</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">[]</span></span></li><li><span id="innerjoinlastarg"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">LastArg</span></span></li><li><span id="innerjoinjoinedassociationscandidate"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">JoinedAssociationsCandidate</span> = <span class="tsd-signature-type">JoinedAssociationsTypeFromAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoindb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjointablename">TableName</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li><li><span id="innerjoinjoinedassociations"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">JoinedAssociations</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span> = <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span></span></li><li><span id="innerjoinretquery"><span class="tsd-kind-type-parameter">RetQuery</span> = <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLeftJoinPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPaginate"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinjoinedassociations">JoinedAssociations</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span>: <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span></span><div class="tsd-comment tsd-typography"><p>A chain of association names and and/andNot/andAny clauses</p>
|
|
349
361
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="#innerjoinretquery">RetQuery</a></h4><p>A cloned Query with the joins clause applied</p>
|
|
350
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
362
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L882">src/dream/Query.ts:882</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="last"><span>last</span><a href="#last" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="last-1"><span class="tsd-kind-call-signature">last</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">></span><a href="#last-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns the last record in the database
|
|
351
363
|
matching the Query. If the Query is not
|
|
352
364
|
ordered, it will automatically order
|
|
353
365
|
by primary key.</p>
|
|
@@ -355,7 +367,7 @@ by primary key.</p>
|
|
|
355
367
|
</code><button type="button">Copy</button></pre>
|
|
356
368
|
|
|
357
369
|
</div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">></span></h4><p>Last record in the database, or null if no record exists</p>
|
|
358
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
370
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2533">src/dream/Query.ts:2533</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="lastorfail"><span>last<wbr/>Or<wbr/>Fail</span><a href="#lastorfail" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="lastorfail-1"><span class="tsd-kind-call-signature">lastOrFail</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><a href="#lastorfail-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns the last record in the database
|
|
359
371
|
matching the Query. If the Query is not
|
|
360
372
|
ordered, it will automatically order
|
|
361
373
|
by primary key. If no record is found,
|
|
@@ -364,10 +376,10 @@ it will raise an exception.</p>
|
|
|
364
376
|
</code><button type="button">Copy</button></pre>
|
|
365
377
|
|
|
366
378
|
</div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></h4><p>Last record in the database</p>
|
|
367
|
-
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-
|
|
368
|
-
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/276ab87aae35de8dce4d5a4e3052373f512d2717/src/dream/Query.ts#L2518">src/dream/Query.ts:2518</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="leftjoin"><span>left<wbr/>Join</span><a href="#leftjoin" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="leftjoin-1"><span class="tsd-kind-call-signature">leftJoin</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoindb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinschema">Schema</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjointablename">TableName</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinarr">Arr</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinlastarg">LastArg</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-type">JoinedAssociationsTypeFromAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoindb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjointablename">TableName</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span><br/> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span> <span class="tsd-signature-symbol">=</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinretquery">RetQuery</a> <span class="tsd-signature-symbol">=</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLeftJoinPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPaginate"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociations">JoinedAssociations</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinretquery">RetQuery</a><a href="#leftjoin-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><code class="tsd-tag">Internal</code><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="leftjoindb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="leftjoinschema"><span class="tsd-kind-type-parameter">Schema</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="leftjointablename"><span class="tsd-kind-type-parameter">TableName</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span></span></li><li><span id="leftjoinarr"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">Arr</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">[]</span></span></li><li><span id="leftjoinlastarg"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">LastArg</span></span></li><li><span id="leftjoinjoinedassociationscandidate"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">JoinedAssociationsCandidate</span> = <span class="tsd-signature-type">JoinedAssociationsTypeFromAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoindb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjointablename">TableName</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li><li><span id="leftjoinjoinedassociations"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">JoinedAssociations</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span> = <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span></span></li><li><span id="leftjoinretquery"><span class="tsd-kind-type-parameter">RetQuery</span> = <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLeftJoinPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPaginate"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociations">JoinedAssociations</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span>: <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span></span><div class="tsd-comment tsd-typography"><p>A chain of association names and and/andNot/andAny clauses</p>
|
|
379
|
+
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-4">Throws<a href="#throws-4" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>RecordNotFound if no record exists</p>
|
|
380
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2557">src/dream/Query.ts:2557</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="leftjoin"><span>left<wbr/>Join</span><a href="#leftjoin" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="leftjoin-1"><span class="tsd-kind-call-signature">leftJoin</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoindb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinschema">Schema</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjointablename">TableName</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinarr">Arr</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinlastarg">LastArg</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-type">JoinedAssociationsTypeFromAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoindb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjointablename">TableName</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span><br/> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span> <span class="tsd-signature-symbol">=</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinretquery">RetQuery</a> <span class="tsd-signature-symbol">=</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLeftJoinPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPaginate"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociations">JoinedAssociations</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinretquery">RetQuery</a><a href="#leftjoin-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><code class="tsd-tag">Internal</code><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="leftjoindb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="leftjoinschema"><span class="tsd-kind-type-parameter">Schema</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="leftjointablename"><span class="tsd-kind-type-parameter">TableName</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span></span></li><li><span id="leftjoinarr"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">Arr</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">[]</span></span></li><li><span id="leftjoinlastarg"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">LastArg</span></span></li><li><span id="leftjoinjoinedassociationscandidate"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">JoinedAssociationsCandidate</span> = <span class="tsd-signature-type">JoinedAssociationsTypeFromAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoindb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjointablename">TableName</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li><li><span id="leftjoinjoinedassociations"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">JoinedAssociations</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span> = <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociationscandidate">JoinedAssociationsCandidate</a><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span></span></li><li><span id="leftjoinretquery"><span class="tsd-kind-type-parameter">RetQuery</span> = <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLeftJoinPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPaginate"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinjoinedassociations">JoinedAssociations</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span>: <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinlastarg">LastArg</a><span class="tsd-signature-symbol">]</span></span><div class="tsd-comment tsd-typography"><p>A chain of association names and and/andNot/andAny clauses</p>
|
|
369
381
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinretquery">RetQuery</a></h4><p>A cloned Query with the joins clause applied</p>
|
|
370
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/276ab87aae35de8dce4d5a4e3052373f512d2717/src/dream/Query.ts#L920">src/dream/Query.ts:920</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="leftjoinpreload"><span>left<wbr/>Join<wbr/>Preload</span><a href="#leftjoinpreload" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="leftjoinpreload-1"><span class="tsd-kind-call-signature">leftJoinPreload</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloaddb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadschema">Schema</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadtablename">TableName</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadarr">Arr</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadlastarg">LastArg</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-type">JoinedAssociationsTypeFromAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloaddb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadtablename">TableName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span><br/> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span> <span class="tsd-signature-symbol">=</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociationscandidate">JoinedAssociationsCandidate</a><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadretquery">RetQuery</a> <span class="tsd-signature-symbol">=</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLeftJoinPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociations">JoinedAssociations</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadq">Q</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"leftJoinPreload is incompatible with preload, limit, offset, and paginate"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadretquery">RetQuery</a><a href="#leftjoinpreload-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Load each specified association using a single SQL query.
|
|
382
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L937">src/dream/Query.ts:937</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="leftjoinpreload"><span>left<wbr/>Join<wbr/>Preload</span><a href="#leftjoinpreload" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="leftjoinpreload-1"><span class="tsd-kind-call-signature">leftJoinPreload</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloaddb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadschema">Schema</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadtablename">TableName</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadarr">Arr</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadlastarg">LastArg</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-symbol">=</span> <span class="tsd-signature-type">JoinedAssociationsTypeFromAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloaddb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadtablename">TableName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span><br/> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span> <span class="tsd-signature-symbol">=</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociationscandidate">JoinedAssociationsCandidate</a><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadretquery">RetQuery</a> <span class="tsd-signature-symbol">=</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLeftJoinPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociations">JoinedAssociations</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadq">Q</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"leftJoinPreload is incompatible with preload, limit, offset, and paginate"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadretquery">RetQuery</a><a href="#leftjoinpreload-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Load each specified association using a single SQL query.
|
|
371
383
|
See <a href="#preload" class="tsd-kind-method">Query.preload</a> for preloading in separate queries.</p>
|
|
372
384
|
<p>Note: since leftJoinPreload loads via single query, it has
|
|
373
385
|
some downsides and that may be avoided using <a href="#preload" class="tsd-kind-method">Query.preload</a>:</p>
|
|
@@ -394,19 +406,24 @@ stops naming it a full deploy before the column is actually dropped.</li>
|
|
|
394
406
|
|
|
395
407
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="leftjoinpreloadq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span></li><li><span id="leftjoinpreloaddb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="leftjoinpreloadschema"><span class="tsd-kind-type-parameter">Schema</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="leftjoinpreloadtablename"><span class="tsd-kind-type-parameter">TableName</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span></span></li><li><span id="leftjoinpreloadarr"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">Arr</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">[]</span></span></li><li><span id="leftjoinpreloadlastarg"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">LastArg</span></span></li><li><span id="leftjoinpreloadincompatible"><span class="tsd-kind-type-parameter">Incompatible</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span></span></li><li><span id="leftjoinpreloadjoinedassociationscandidate"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">JoinedAssociationsCandidate</span> = <span class="tsd-signature-type">JoinedAssociationsTypeFromAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloaddb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadtablename">TableName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadlastarg">LastArg</a><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li><li><span id="leftjoinpreloadjoinedassociations"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">JoinedAssociations</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span> = <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociationscandidate">JoinedAssociationsCandidate</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociationscandidate">JoinedAssociationsCandidate</a><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span></span></li><li><span id="leftjoinpreloadretquery"><span class="tsd-kind-type-parameter">RetQuery</span> = <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLeftJoinPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociations">JoinedAssociations</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">JoinedAssociation</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-symbol">[</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadjoinedassociations">JoinedAssociations</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadq">Q</a></span></li><li><span><span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"leftJoinPreload is incompatible with preload, limit, offset, and paginate"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadlastarg">LastArg</a><span class="tsd-signature-symbol">]</span></span><div class="tsd-comment tsd-typography"><p>A chain of association names and and/andNot/andAny clauses</p>
|
|
396
408
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="#leftjoinpreloadretquery">RetQuery</a></h4><p>A cloned Query with the joinLoad statement applied</p>
|
|
397
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
409
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L682">src/dream/Query.ts:682</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="limit"><span>limit</span><a href="#limit" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="limit-1"><span class="tsd-kind-call-signature">limit</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#limitq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#limitincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#limitretquery">RetQuery</a> <span class="tsd-signature-symbol">=</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#limitq">Q</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">limit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#limitincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"limit is incompatible with paginate and leftJoinPreload"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#limitretquery">RetQuery</a><a href="#limit-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns a new Query instance, specifying a limit</p>
|
|
398
410
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">order</span><span class="hl-1">(</span><span class="hl-6">'id'</span><span class="hl-1">).</span><span class="hl-5">limit</span><span class="hl-1">(</span><span class="hl-8">2</span><span class="hl-1">).</span><span class="hl-5">all</span><span class="hl-1">()</span><br/><span class="hl-7">// [User{id: 1}, User{id: 2}]</span>
|
|
399
411
|
</code><button type="button">Copy</button></pre>
|
|
400
412
|
|
|
413
|
+
<p>A limit is incompatible with <code>paginate</code> and <code>leftJoinPreload</code>, and with
|
|
414
|
+
the batched and set-write operations — <code>findEach</code>, <code>pluckEach</code>,
|
|
415
|
+
<code>destroy</code>, <code>reallyDestroy</code>, <code>undestroy</code>, and <code>update</code> — none of which can
|
|
416
|
+
honor one: the batched and set-write operations throw
|
|
417
|
+
<code>BatchingIncompatibleWithLimitOrOffset</code> on a limit-carrying Query.</p>
|
|
401
418
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="limitq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span></li><li><span id="limitincompatible"><span class="tsd-kind-type-parameter">Incompatible</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span></span></li><li><span id="limitretquery"><span class="tsd-kind-type-parameter">RetQuery</span> = <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#limitq">Q</a></span></li><li><span><span class="tsd-kind-parameter">limit</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#limitincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"limit is incompatible with paginate and leftJoinPreload"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="#limitretquery">RetQuery</a></h4><p>A cloned Query with the limit clause applied</p>
|
|
402
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
419
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1427">src/dream/Query.ts:1427</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="max"><span>max</span><a href="#max" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="max-1"><span class="tsd-kind-call-signature">max</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxdb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxcolumnname">ColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxreturntype">ReturnType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">columnName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxcolumnname">ColumnName</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#maxreturntype">ReturnType</a><span class="tsd-signature-symbol">></span><a href="#max-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Retrieves the max value of the specified column
|
|
403
420
|
for this Query</p>
|
|
404
421
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">max</span><span class="hl-1">(</span><span class="hl-6">'id'</span><span class="hl-1">)</span><br/><span class="hl-7">// 99</span>
|
|
405
422
|
</code><button type="button">Copy</button></pre>
|
|
406
423
|
|
|
407
424
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="maxq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span id="maxdb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="maxcolumnname"><span class="tsd-kind-type-parameter">ColumnName</span></span></li><li><span id="maxreturntype"><span class="tsd-kind-type-parameter">ReturnType</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">columnName</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxcolumnname">ColumnName</a></span><div class="tsd-comment tsd-typography"><p>a column name on the model</p>
|
|
408
425
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#maxreturntype">ReturnType</a><span class="tsd-signature-symbol">></span></h4><p>the max value of the specified column for this Query</p>
|
|
409
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
426
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1684">src/dream/Query.ts:1684</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="maxby"><span>max<wbr/>By</span><a href="#maxby" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="maxby-1"><span class="tsd-kind-call-signature">maxBy</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbyq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbydb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbygroupcolumnname">GroupColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbyaggregatedcolumnname">AggregatedColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbygroupkey">GroupKey</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbyaggregatedtype">AggregatedType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">groupColumn</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbygroupcolumnname">GroupColumnName</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">aggregatedColumn</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbyaggregatedcolumnname">AggregatedColumnName</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbygroupkey">GroupKey</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbyaggregatedtype">AggregatedType</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span><a href="#maxby-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Retrieves the max value of the specified column within each group, keyed by
|
|
410
427
|
the value of the provided group column (a SQL <code>GROUP BY</code>).</p>
|
|
411
428
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">CompositionAsset</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">maxBy</span><span class="hl-1">(</span><span class="hl-6">'name'</span><span class="hl-1">, </span><span class="hl-6">'score'</span><span class="hl-1">)</span><br/><span class="hl-7">// Map(2) { 'primary' => 9, 'secondary' => 4 }</span>
|
|
412
429
|
</code><button type="button">Copy</button></pre>
|
|
@@ -422,14 +439,14 @@ are grouped under a real <code>null</code> key; a group whose aggregated values
|
|
|
422
439
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="maxbyq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span id="maxbydb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="maxbygroupcolumnname"><span class="tsd-kind-type-parameter">GroupColumnName</span></span></li><li><span id="maxbyaggregatedcolumnname"><span class="tsd-kind-type-parameter">AggregatedColumnName</span></span></li><li><span id="maxbygroupkey"><span class="tsd-kind-type-parameter">GroupKey</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="maxbyaggregatedtype"><span class="tsd-kind-type-parameter">AggregatedType</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">groupColumn</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbygroupcolumnname">GroupColumnName</a></span><div class="tsd-comment tsd-typography"><p>the column to group by (base or joined-association-namespaced)</p>
|
|
423
440
|
</div></li><li><span><span class="tsd-kind-parameter">aggregatedColumn</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbyaggregatedcolumnname">AggregatedColumnName</a></span><div class="tsd-comment tsd-typography"><p>the column to take the max of within each group</p>
|
|
424
441
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbygroupkey">GroupKey</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#maxbyaggregatedtype">AggregatedType</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span></h4><p>A Map from each present group value to the max of the aggregated column in that group</p>
|
|
425
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
442
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1721">src/dream/Query.ts:1721</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="min"><span>min</span><a href="#min" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="min-1"><span class="tsd-kind-call-signature">min</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#minq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#mindb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#mincolumnname">ColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#minreturntype">ReturnType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">columnName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#mincolumnname">ColumnName</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#minreturntype">ReturnType</a><span class="tsd-signature-symbol">></span><a href="#min-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Retrieves the min value of the specified column
|
|
426
443
|
for this Query</p>
|
|
427
444
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">min</span><span class="hl-1">(</span><span class="hl-6">'id'</span><span class="hl-1">)</span><br/><span class="hl-7">// 1</span>
|
|
428
445
|
</code><button type="button">Copy</button></pre>
|
|
429
446
|
|
|
430
447
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="minq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span id="mindb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="mincolumnname"><span class="tsd-kind-type-parameter">ColumnName</span></span></li><li><span id="minreturntype"><span class="tsd-kind-type-parameter">ReturnType</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">columnName</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#mincolumnname">ColumnName</a></span><div class="tsd-comment tsd-typography"><p>a column name on the model</p>
|
|
431
448
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#minreturntype">ReturnType</a><span class="tsd-signature-symbol">></span></h4><p>the min value of the specified column for this Query</p>
|
|
432
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
449
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1757">src/dream/Query.ts:1757</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="minby"><span>min<wbr/>By</span><a href="#minby" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="minby-1"><span class="tsd-kind-call-signature">minBy</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#minbyq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#minbydb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#minbygroupcolumnname">GroupColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#minbyaggregatedcolumnname">AggregatedColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#minbygroupkey">GroupKey</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#minbyaggregatedtype">AggregatedType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">groupColumn</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#minbygroupcolumnname">GroupColumnName</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">aggregatedColumn</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#minbyaggregatedcolumnname">AggregatedColumnName</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#minbygroupkey">GroupKey</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#minbyaggregatedtype">AggregatedType</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span><a href="#minby-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Retrieves the min value of the specified column within each group, keyed by
|
|
433
450
|
the value of the provided group column (a SQL <code>GROUP BY</code>).</p>
|
|
434
451
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">CompositionAsset</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">minBy</span><span class="hl-1">(</span><span class="hl-6">'name'</span><span class="hl-1">, </span><span class="hl-6">'score'</span><span class="hl-1">)</span><br/><span class="hl-7">// Map(2) { 'primary' => 1, 'secondary' => 4 }</span>
|
|
435
452
|
</code><button type="button">Copy</button></pre>
|
|
@@ -445,19 +462,24 @@ are grouped under a real <code>null</code> key; a group whose aggregated values
|
|
|
445
462
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="minbyq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span id="minbydb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="minbygroupcolumnname"><span class="tsd-kind-type-parameter">GroupColumnName</span></span></li><li><span id="minbyaggregatedcolumnname"><span class="tsd-kind-type-parameter">AggregatedColumnName</span></span></li><li><span id="minbygroupkey"><span class="tsd-kind-type-parameter">GroupKey</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="minbyaggregatedtype"><span class="tsd-kind-type-parameter">AggregatedType</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">groupColumn</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#minbygroupcolumnname">GroupColumnName</a></span><div class="tsd-comment tsd-typography"><p>the column to group by (base or joined-association-namespaced)</p>
|
|
446
463
|
</div></li><li><span><span class="tsd-kind-parameter">aggregatedColumn</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#minbyaggregatedcolumnname">AggregatedColumnName</a></span><div class="tsd-comment tsd-typography"><p>the column to take the min of within each group</p>
|
|
447
464
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#minbygroupkey">GroupKey</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#minbyaggregatedtype">AggregatedType</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span></h4><p>A Map from each present group value to the min of the aggregated column in that group</p>
|
|
448
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
465
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1794">src/dream/Query.ts:1794</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="nestedselect"><span>nested<wbr/>Select</span><a href="#nestedselect" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="nestedselect-1"><span class="tsd-kind-call-signature">nestedSelect</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#nestedselectsimplefieldtype">SimpleFieldType</a> <span class="tsd-signature-keyword">extends</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">number</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <span class="tsd-signature-type">iterator</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"toString"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"charAt"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"charCodeAt"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"concat"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"indexOf"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"lastIndexOf"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"localeCompare"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"match"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"replace"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"search"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"slice"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"split"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"substring"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"toLowerCase"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"toLocaleLowerCase"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"toUpperCase"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"toLocaleUpperCase"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"trim"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"length"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"substr"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"valueOf"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"codePointAt"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"includes"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"endsWith"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"normalize"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"repeat"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"startsWith"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"anchor"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"big"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"blink"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"bold"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"fixed"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"fontcolor"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"fontsize"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"italics"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"link"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"small"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"strike"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"sub"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"sup"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"padStart"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"padEnd"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"trimEnd"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"trimStart"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"trimLeft"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"trimRight"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"matchAll"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"replaceAll"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"at"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"toLocaleString"</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#nestedselectpluckthroughfieldtype">PluckThroughFieldType</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">selection</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#nestedselectsimplefieldtype">SimpleFieldType</a> <span class="tsd-signature-symbol">|</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#nestedselectpluckthroughfieldtype">PluckThroughFieldType</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">SelectQueryBuilder</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><a href="#nestedselect-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns a new Kysely SelectQueryBuilder instance to be used
|
|
449
466
|
in a sub Query</p>
|
|
450
467
|
<pre><code class="ts"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">records</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-4">id:</span><span class="hl-1"> </span><span class="hl-4">Post</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">nestedSelect</span><span class="hl-1">(</span><span class="hl-6">'userId'</span><span class="hl-1">),</span><br/><span class="hl-1">}).</span><span class="hl-5">all</span><span class="hl-1">()</span><br/><span class="hl-7">// [User{id: 1}, ...]</span>
|
|
451
468
|
</code><button type="button">Copy</button></pre>
|
|
452
469
|
|
|
453
470
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="nestedselectsimplefieldtype"><span class="tsd-kind-type-parameter">SimpleFieldType</span> <span class="tsd-signature-keyword">extends</span> <br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">number</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-keyword">typeof</span> <span class="tsd-signature-type">iterator</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"toString"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"charAt"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"charCodeAt"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"concat"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"indexOf"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"lastIndexOf"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"localeCompare"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"match"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"replace"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"search"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"slice"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"split"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"substring"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"toLowerCase"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"toLocaleLowerCase"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"toUpperCase"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"toLocaleUpperCase"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"trim"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"length"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"substr"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"valueOf"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"codePointAt"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"includes"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"endsWith"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"normalize"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"repeat"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"startsWith"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"anchor"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"big"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"blink"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"bold"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"fixed"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"fontcolor"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"fontsize"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"italics"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"link"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"small"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"strike"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"sub"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"sup"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"padStart"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"padEnd"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"trimEnd"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"trimStart"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"trimLeft"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"trimRight"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"matchAll"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"replaceAll"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"at"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"toLocaleString"</span></span></li><li><span id="nestedselectpluckthroughfieldtype"><span class="tsd-kind-type-parameter">PluckThroughFieldType</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span><span class="tsd-kind-parameter">selection</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#nestedselectsimplefieldtype">SimpleFieldType</a> <span class="tsd-signature-symbol">|</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#nestedselectpluckthroughfieldtype">PluckThroughFieldType</a></span><div class="tsd-comment tsd-typography"><p>the column to use for your nested Query</p>
|
|
454
471
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">SelectQueryBuilder</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></h4><p>A Kysely SelectQueryBuilder instance</p>
|
|
455
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
472
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1359">src/dream/Query.ts:1359</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="offset"><span>offset</span><a href="#offset" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="offset-1"><span class="tsd-kind-call-signature">offset</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#offsetq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#offsetincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#offsetretquery">RetQuery</a> <span class="tsd-signature-symbol">=</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#offsetq">Q</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">offset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#offsetincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"offset is incompatible with paginate and leftJoinPreload"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#offsetretquery">RetQuery</a><a href="#offset-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns a new Query instance, specifying an offset</p>
|
|
456
473
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">order</span><span class="hl-1">(</span><span class="hl-6">'id'</span><span class="hl-1">).</span><span class="hl-5">offset</span><span class="hl-1">(</span><span class="hl-8">2</span><span class="hl-1">).</span><span class="hl-5">limit</span><span class="hl-1">(</span><span class="hl-8">2</span><span class="hl-1">).</span><span class="hl-5">all</span><span class="hl-1">()</span><br/><span class="hl-7">// [User{id: 3}, User{id: 4}]</span>
|
|
457
474
|
</code><button type="button">Copy</button></pre>
|
|
458
475
|
|
|
476
|
+
<p>An offset is incompatible with <code>paginate</code> and <code>leftJoinPreload</code>, and with
|
|
477
|
+
the batched and set-write operations — <code>findEach</code>, <code>pluckEach</code>,
|
|
478
|
+
<code>destroy</code>, <code>reallyDestroy</code>, <code>undestroy</code>, and <code>update</code> — none of which can
|
|
479
|
+
honor one: the batched and set-write operations throw
|
|
480
|
+
<code>BatchingIncompatibleWithLimitOrOffset</code> on an offset-carrying Query.</p>
|
|
459
481
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="offsetq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span></li><li><span id="offsetincompatible"><span class="tsd-kind-type-parameter">Incompatible</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span></span></li><li><span id="offsetretquery"><span class="tsd-kind-type-parameter">RetQuery</span> = <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#offsetq">Q</a></span></li><li><span><span class="tsd-kind-parameter">offset</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#offsetincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"offset is incompatible with paginate and leftJoinPreload"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">number</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="#offsetretquery">RetQuery</a></h4><p>A cloned Query with the offset clause applied</p>
|
|
460
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
482
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1465">src/dream/Query.ts:1465</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="order"><span>order</span><a href="#order" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="order-1"><span class="tsd-kind-call-signature">order</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#orderq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#orderdb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#ordercolumnname">ColumnName</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">arg</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#ordercolumnname">ColumnName</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#ordercolumnname">ColumnName</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">OrderDir</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#order-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns a new Query instance, attaching the provided
|
|
461
483
|
order statement</p>
|
|
462
484
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">order</span><span class="hl-1">(</span><span class="hl-6">'id'</span><span class="hl-1">).</span><span class="hl-5">all</span><span class="hl-1">()</span><br/><span class="hl-7">// [User{id: 1}, User{id: 2}, ...]</span>
|
|
463
485
|
</code><button type="button">Copy</button></pre>
|
|
@@ -467,7 +489,7 @@ order statement</p>
|
|
|
467
489
|
|
|
468
490
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="orderq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span id="orderdb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="ordercolumnname"><span class="tsd-kind-type-parameter">ColumnName</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">arg</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#ordercolumnname">ColumnName</a> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#ordercolumnname">ColumnName</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">OrderDir</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span></span><div class="tsd-comment tsd-typography"><p>Either a string or an object specifying order. If a string, the order is implicitly ascending. If the orderStatement is an object, statements will be provided in the order of the keys set in the object</p>
|
|
469
491
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><p>A cloned Query with the order clause applied</p>
|
|
470
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
492
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1384">src/dream/Query.ts:1384</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="paginate"><span>paginate</span><a href="#paginate" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="paginate-1"><span class="tsd-kind-call-signature">paginate</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#paginateq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#paginateincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#paginateq">Q</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">opts</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#paginateincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"paginate is incompatible with limit, offset, and leftJoinPreload"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">PaginatedDreamQueryOptions</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">PaginatedDreamQueryResult</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span><a href="#paginate-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Paginates the results of your query, accepting a pageSize and page argument,
|
|
471
493
|
which it uses to segment your query into pages, leveraging limit and offset
|
|
472
494
|
to deliver your query to you in pages.</p>
|
|
473
495
|
<pre><code class="ts"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">paginated</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">order</span><span class="hl-1">(</span><span class="hl-6">'email'</span><span class="hl-1">).</span><span class="hl-5">paginate</span><span class="hl-1">({ </span><span class="hl-4">pageSize:</span><span class="hl-1"> </span><span class="hl-8">100</span><span class="hl-1">, </span><span class="hl-4">page:</span><span class="hl-1"> </span><span class="hl-8">2</span><span class="hl-1"> })</span><br/><span class="hl-4">paginated</span><span class="hl-1">.</span><span class="hl-4">results</span><br/><span class="hl-7">// [ { User{id: 101}, User{id: 102}, ...}]</span><br/><br/><span class="hl-4">paginated</span><span class="hl-1">.</span><span class="hl-4">recordCount</span><br/><span class="hl-7">// 350</span><br/><br/><span class="hl-4">paginated</span><span class="hl-1">.</span><span class="hl-4">pageCount</span><br/><span class="hl-7">// 4</span><br/><br/><span class="hl-4">paginated</span><span class="hl-1">.</span><span class="hl-4">currentPage</span><br/><span class="hl-7">// 2</span>
|
|
@@ -475,14 +497,14 @@ to deliver your query to you in pages.</p>
|
|
|
475
497
|
|
|
476
498
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="paginateq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span></li><li><span id="paginateincompatible"><span class="tsd-kind-type-parameter">Incompatible</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#paginateq">Q</a></span></li><li><span><span class="tsd-kind-parameter">opts</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#paginateincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"paginate is incompatible with limit, offset, and leftJoinPreload"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">PaginatedDreamQueryOptions</span></span><div class="tsd-comment tsd-typography"><p>Pagination options</p>
|
|
477
499
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">PaginatedDreamQueryResult</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span></h4><p>results.recordCount - A number representing the total number of records matching your query</p>
|
|
478
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
500
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2171">src/dream/Query.ts:2171</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="passthrough"><span>passthrough</span><a href="#passthrough" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="passthrough-1"><span class="tsd-kind-call-signature">passthrough</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">passthroughOnStatement</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">PassthroughOnClause</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">PassthroughColumnNames</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#passthrough-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Sends data through for use as passthrough data
|
|
479
501
|
for the associations that require it.</p>
|
|
480
502
|
<pre><code class="ts"><span class="hl-0">class</span><span class="hl-1"> </span><span class="hl-9">Post</span><span class="hl-1"> {</span><br/><span class="hl-1"> @</span><span class="hl-4">deco</span><span class="hl-1">.</span><span class="hl-5">HasMany</span><span class="hl-1">(</span><span class="hl-6">'LocalizedText'</span><span class="hl-1">)</span><br/><span class="hl-1"> </span><span class="hl-0">public</span><span class="hl-1"> </span><span class="hl-4">localizedTexts</span><span class="hl-1">: </span><span class="hl-9">LocalizedText</span><span class="hl-1">[]</span><br/><br/><span class="hl-1"> @</span><span class="hl-4">deco</span><span class="hl-1">.</span><span class="hl-5">HasOne</span><span class="hl-1">(</span><span class="hl-6">'LocalizedText'</span><span class="hl-1">, {</span><br/><span class="hl-1"> </span><span class="hl-4">and:</span><span class="hl-1"> { </span><span class="hl-4">locale:</span><span class="hl-1"> </span><span class="hl-4">DreamConst</span><span class="hl-1">.</span><span class="hl-4">passthrough</span><span class="hl-1"> },</span><br/><span class="hl-1"> })</span><br/><span class="hl-1"> </span><span class="hl-0">public</span><span class="hl-1"> </span><span class="hl-4">currentLocalizedText</span><span class="hl-1">: </span><span class="hl-9">LocalizedText</span><br/><span class="hl-1">}</span><br/><br/><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">passthrough</span><span class="hl-1">({ </span><span class="hl-4">locale:</span><span class="hl-1"> </span><span class="hl-6">'es-ES'</span><span class="hl-1"> })</span><br/><span class="hl-1"> .</span><span class="hl-5">preload</span><span class="hl-1">(</span><span class="hl-6">'posts'</span><span class="hl-1">, </span><span class="hl-6">'currentLocalizedText'</span><span class="hl-1">)</span><br/><span class="hl-1"> .</span><span class="hl-5">first</span><span class="hl-1">()</span>
|
|
481
503
|
</code><button type="button">Copy</button></pre>
|
|
482
504
|
|
|
483
505
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">passthroughOnStatement</span>: <span class="tsd-signature-type">PassthroughOnClause</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">PassthroughColumnNames</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span></span><div class="tsd-comment tsd-typography"><p>where statement used for associations that require passthrough data</p>
|
|
484
506
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><p>A cloned Query with the passthrough data</p>
|
|
485
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
507
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1251">src/dream/Query.ts:1251</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="pluck"><span>pluck</span><a href="#pluck" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="pluck-1"><span class="tsd-kind-call-signature">pluck</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckdb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckcolumnnames">ColumnNames</a> <span class="tsd-signature-keyword">extends</span><br/> <span class="tsd-signature-type">ColumnNamesAccountingForJoinedAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckq">Q</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"queryTypeOpts"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckdb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckreturnvalue">ReturnValue</a> <span class="tsd-signature-keyword">extends</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">NamespacedOrBaseModelColumnTypes</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckcolumnnames">ColumnNames</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckq">Q</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">0</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">NamespacedOrBaseModelColumnTypes</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckcolumnnames">ColumnNames</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckq">Q</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckq">Q</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">columnNames</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckcolumnnames">ColumnNames</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckreturnvalue">ReturnValue</a><span class="tsd-signature-symbol">></span><a href="#pluck-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Plucks the provided fields from the given dream class table</p>
|
|
486
508
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">order</span><span class="hl-1">(</span><span class="hl-6">'id'</span><span class="hl-1">).</span><span class="hl-5">pluck</span><span class="hl-1">(</span><span class="hl-6">'id'</span><span class="hl-1">)</span><br/><span class="hl-7">// [1, 2, 3]</span>
|
|
487
509
|
</code><button type="button">Copy</button></pre>
|
|
488
510
|
|
|
@@ -493,22 +515,27 @@ array is returned:</p>
|
|
|
493
515
|
|
|
494
516
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="pluckq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span id="pluckdb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="pluckcolumnnames"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">ColumnNames</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">ColumnNamesAccountingForJoinedAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckq">Q</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"queryTypeOpts"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckdb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[]</span></span></li><li><span id="pluckreturnvalue"><span class="tsd-kind-type-parameter">ReturnValue</span> <span class="tsd-signature-keyword">extends</span> <br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">NamespacedOrBaseModelColumnTypes</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckcolumnnames">ColumnNames</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckq">Q</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">0</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">NamespacedOrBaseModelColumnTypes</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckcolumnnames">ColumnNames</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckq">Q</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[]</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckq">Q</a></span></li><li><span><span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">columnNames</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckcolumnnames">ColumnNames</a></span><div class="tsd-comment tsd-typography"><p>The column or array of columns to pluck</p>
|
|
495
517
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckreturnvalue">ReturnValue</a><span class="tsd-signature-symbol">></span></h4><p>An array of pluck results</p>
|
|
496
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
518
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1983">src/dream/Query.ts:1983</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="pluckeach"><span>pluck<wbr/>Each</span><a href="#pluckeach" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="pluckeach-1"><span class="tsd-kind-call-signature">pluckEach</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachdb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachcolumnnames">ColumnNames</a> <span class="tsd-signature-keyword">extends</span><br/> <span class="tsd-signature-type">ColumnNamesAccountingForJoinedAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachq">Q</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"queryTypeOpts"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachdb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachcbargtypes">CbArgTypes</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachq">Q</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">PluckEachArgs</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachcolumnnames">ColumnNames</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachcbargtypes">CbArgTypes</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span><a href="#pluckeach-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Plucks the specified column names from the given dream class table
|
|
497
519
|
in batches, passing each found columns into the
|
|
498
520
|
provided callback function</p>
|
|
499
521
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">order</span><span class="hl-1">(</span><span class="hl-6">'id'</span><span class="hl-1">).</span><span class="hl-5">pluckEach</span><span class="hl-1">(</span><span class="hl-6">'id'</span><span class="hl-1">, (</span><span class="hl-4">id</span><span class="hl-1">) </span><span class="hl-0">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-4">console</span><span class="hl-1">.</span><span class="hl-5">log</span><span class="hl-1">(</span><span class="hl-4">id</span><span class="hl-1">)</span><br/><span class="hl-1">})</span><br/><span class="hl-7">// 1</span><br/><span class="hl-7">// 2</span><br/><span class="hl-7">// 3</span>
|
|
500
522
|
</code><button type="button">Copy</button></pre>
|
|
501
523
|
|
|
524
|
+
<p>A <code>limit</code> or <code>offset</code> on the Query cannot compose with the batch windows
|
|
525
|
+
— each window replaces the limit with the batch size and the offset with
|
|
526
|
+
the running window offset, silently ignoring both — so a limit- or
|
|
527
|
+
offset-carrying Query throws at runtime.</p>
|
|
502
528
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="pluckeachq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span id="pluckeachdb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="pluckeachcolumnnames"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">ColumnNames</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">ColumnNamesAccountingForJoinedAssociations</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachq">Q</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"queryTypeOpts"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachdb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[]</span></span></li><li><span id="pluckeachcbargtypes"><span class="tsd-kind-type-parameter">CbArgTypes</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">]</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachq">Q</a></span></li><li><span><span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span>: <span class="tsd-signature-type">PluckEachArgs</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachcolumnnames">ColumnNames</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#pluckeachcbargtypes">CbArgTypes</a><span class="tsd-signature-symbol">></span></span><div class="tsd-comment tsd-typography"><p>a list of column names to pluck, followed by a callback function to call for each set of found fields</p>
|
|
503
529
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">void</span><span class="tsd-signature-symbol">></span></h4><p>void</p>
|
|
504
|
-
<
|
|
530
|
+
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-5">Throws<a href="#throws-5" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>BatchingIncompatibleWithLimitOrOffset if the query carries a <code>limit</code> or <code>offset</code></p>
|
|
531
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2024">src/dream/Query.ts:2024</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="preload"><span>preload</span><a href="#preload" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="preload-1"><span class="tsd-kind-call-signature">preload</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloaddb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadschema">Schema</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadtablename">TableName</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-keyword">const</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadarr">Arr</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadretquery">RetQuery</a> <span class="tsd-signature-symbol">=</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPaginate"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadq">Q</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"preload is incompatible with leftJoinPreload"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">VariadicLoadArgs</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloaddb">DB</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadschema">Schema</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadtablename">TableName</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadarr">Arr</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadretquery">RetQuery</a><a href="#preload-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Load each specified association using a separate SQL query.
|
|
505
532
|
See <a href="#leftjoinpreload" class="tsd-kind-method">Query.leftJoinPreload</a> for preloading in a single query.</p>
|
|
506
533
|
<pre><code class="ts"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">user</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">preload</span><span class="hl-1">(</span><span class="hl-6">'posts'</span><span class="hl-1">, </span><span class="hl-6">'comments'</span><span class="hl-1">, { </span><span class="hl-4">visibilty:</span><span class="hl-1"> </span><span class="hl-6">'public'</span><span class="hl-1"> }, </span><span class="hl-6">'replies'</span><span class="hl-1">).</span><span class="hl-5">first</span><span class="hl-1">()</span><br/><span class="hl-4">console</span><span class="hl-1">.</span><span class="hl-5">log</span><span class="hl-1">(</span><span class="hl-4">user</span><span class="hl-1">.</span><span class="hl-4">posts</span><span class="hl-1">[</span><span class="hl-8">0</span><span class="hl-1">].</span><span class="hl-4">comments</span><span class="hl-1">[</span><span class="hl-8">0</span><span class="hl-1">].</span><span class="hl-4">replies</span><span class="hl-1">[</span><span class="hl-8">0</span><span class="hl-1">])</span><br/><span class="hl-7">// [Reply{id: 1}, Reply{id: 2}]</span>
|
|
507
534
|
</code><button type="button">Copy</button></pre>
|
|
508
535
|
|
|
509
536
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="preloadq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span></li><li><span id="preloaddb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="preloadschema"><span class="tsd-kind-type-parameter">Schema</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="preloadtablename"><span class="tsd-kind-type-parameter">TableName</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">string</span></span></li><li><span id="preloadarr"><span class="tsd-signature-keyword">const</span> <span class="tsd-kind-type-parameter">Arr</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">[]</span></span></li><li><span id="preloadincompatible"><span class="tsd-kind-type-parameter">Incompatible</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span></span></li><li><span id="preloadretquery"><span class="tsd-kind-type-parameter">RetQuery</span> = <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPaginate"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadq">Q</a></span></li><li><span><span class="tsd-signature-symbol">...</span><span class="tsd-kind-parameter">args</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"preload is incompatible with leftJoinPreload"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">[</span><span class="tsd-signature-symbol">...</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadarr">Arr</a><span class="tsd-signature-symbol">[]</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">VariadicLoadArgs</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloaddb">DB</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadschema">Schema</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadtablename">TableName</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadarr">Arr</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">]</span></span><div class="tsd-comment tsd-typography"><p>A chain of association names and and/andNot/andAny clauses</p>
|
|
510
537
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadretquery">RetQuery</a></h4><p>A cloned Query with the preload statement applied</p>
|
|
511
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
538
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L744">src/dream/Query.ts:744</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="preloadfor"><span>preload<wbr/>For</span><a href="#preloadfor" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="preloadfor-1"><span class="tsd-kind-call-signature">preloadFor</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadforq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadforserializerkey">SerializerKey</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadforretquery">RetQuery</a> <span class="tsd-signature-symbol">=</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPaginate"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadforq">Q</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">serializerKey</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadforserializerkey">SerializerKey</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">modifierFn</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">LoadForModifierFn</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadforretquery">RetQuery</a><a href="#preloadfor-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Recursively preloads all Dream associations referenced by <code>rendersOne</code> and <code>rendersMany</code>
|
|
512
539
|
in a DreamSerializer. This traverses the entire content tree of serializers to automatically
|
|
513
540
|
load all necessary associations, eliminating N+1 query problems and removing the need to
|
|
514
541
|
manually remember which associations to preload for serialization.</p>
|
|
@@ -525,7 +552,7 @@ automatically preloads all associations that will be needed during serialization
|
|
|
525
552
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="preloadforq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span></li><li><span id="preloadforserializerkey"><span class="tsd-kind-type-parameter">SerializerKey</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="preloadforretquery"><span class="tsd-kind-type-parameter">RetQuery</span> = <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">Readonly</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">allowLeftJoinPreload</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowLimit</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowLimit"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowOffset</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowOffset"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPaginate</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPaginate"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">allowPreload</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"allowPreload"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">joinedAssociations</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableAlias</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableAlias"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">rootTableName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadforq">Q</a></span></li><li><span><span class="tsd-kind-parameter">serializerKey</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadforserializerkey">SerializerKey</a></span><div class="tsd-comment tsd-typography"><p>The serializer key to use for determining which associations to preload.</p>
|
|
526
553
|
</div></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">modifierFn</span>: <span class="tsd-signature-type">LoadForModifierFn</span></span><div class="tsd-comment tsd-typography"><p>Optional callback function to modify or omit specific associations during preloading. Called for each association with the Dream class and association name. Return an object with <code>and</code>, <code>andAny</code>, or <code>andNot</code> properties to add where conditions, return 'omit' to skip preloading that association (useful when you want to handle it manually), or return undefined to use default preloading</p>
|
|
527
554
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="#preloadforretquery">RetQuery</a></h4><p>A Query with all serialization associations preloaded</p>
|
|
528
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
555
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L820">src/dream/Query.ts:820</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="reallydestroy"><span>really<wbr/>Destroy</span><a href="#reallydestroy" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="reallydestroy-1"><span class="tsd-kind-call-signature">reallyDestroy</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">cascade</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span><a href="#reallydestroy-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Destroys all records matching the Query,
|
|
529
556
|
ignoring the SoftDelete decorator and
|
|
530
557
|
permanently removing records from the database.</p>
|
|
531
558
|
<p>Calls model hooks and applies cascade destroy
|
|
@@ -537,26 +564,30 @@ decorator, use <a href="#destroy" class="tsd-kind-method">Query.destroy</a> inst
|
|
|
537
564
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-4">ops</span><span class="hl-1">.</span><span class="hl-5">ilike</span><span class="hl-1">(</span><span class="hl-6">'%burpcollaborator%'</span><span class="hl-1">) }).</span><span class="hl-5">reallyDestroy</span><span class="hl-1">()</span><br/><span class="hl-7">// 12</span>
|
|
538
565
|
</code><button type="button">Copy</button></pre>
|
|
539
566
|
|
|
540
|
-
|
|
567
|
+
<p>A <code>limit</code> or <code>offset</code> on the Query is incompatible with <code>reallyDestroy</code>,
|
|
568
|
+
exactly as it is with <a href="#destroy" class="tsd-kind-method">Query.destroy</a>: a limit- or offset-carrying
|
|
569
|
+
Query throws at runtime.</p>
|
|
570
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">cascade</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol"> = {}</span></span><div class="tsd-comment tsd-typography"><p>Options for destroying the instance</p>
|
|
541
571
|
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><p>The number of records to process per batch. Must be a positive integer. Defaults to 10 when <code>lock</code> is true, and to 1000 otherwise</p>
|
|
542
572
|
</div></li><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">cascade</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>If false, skips destroying associations marked <code>dependent: 'destroy'</code>. Defaults to true</p>
|
|
543
573
|
</div></li><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>If true, each batch is re-selected with an exclusive row lock inside its own transaction before being destroyed, making the destroy a compare-and-set. See <a href="#destroy" class="tsd-kind-method">Query.destroy</a> for the full semantics. Defaults to false</p>
|
|
544
574
|
</div></li><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>If true, skips applying model hooks during the destroy operation. Defaults to false</p>
|
|
545
575
|
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span></h4><p>The number of records that were removed</p>
|
|
546
|
-
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-
|
|
547
|
-
</div
|
|
576
|
+
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-6">Throws<a href="#throws-6" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>InvalidBatchSize if <code>batchSize</code> is not a positive integer</p>
|
|
577
|
+
</div><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-7">Throws<a href="#throws-7" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>BatchingIncompatibleWithLimitOrOffset if the query carries a <code>limit</code> or <code>offset</code></p>
|
|
578
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2881">src/dream/Query.ts:2881</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="removealldefaultscopes"><span>remove<wbr/>All<wbr/>Default<wbr/>Scopes</span><a href="#removealldefaultscopes" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="removealldefaultscopes-1"><span class="tsd-kind-call-signature">removeAllDefaultScopes</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#removealldefaultscopes-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Prevents default scopes from applying when
|
|
548
579
|
the Query is executed</p>
|
|
549
580
|
</div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><p>A new Query which will prevent default scopes from applying</p>
|
|
550
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
581
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1175">src/dream/Query.ts:1175</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member tsd-is-protected"><h3 class="tsd-anchor-link" id="removealldefaultscopesexceptonassociations"><code class="tsd-tag">Protected</code><span>remove<wbr/>All<wbr/>Default<wbr/>Scopes<wbr/>Except<wbr/>On<wbr/>Associations</span><a href="#removealldefaultscopesexceptonassociations" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-protected"><li class=""><div class="tsd-signature tsd-anchor-link" id="removealldefaultscopesexceptonassociations-1"><span class="tsd-kind-call-signature">removeAllDefaultScopesExceptOnAssociations</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><a href="#removealldefaultscopesexceptonassociations-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Prevents default scopes from applying when
|
|
551
582
|
the Query is executed, but not when applying to associations</p>
|
|
552
583
|
</div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><p>A new Query which will prevent default scopes from applying, but not when applying to asociations</p>
|
|
553
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
584
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1188">src/dream/Query.ts:1188</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="removedefaultscope"><span>remove<wbr/>Default<wbr/>Scope</span><a href="#removedefaultscope" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="removedefaultscope-1"><span class="tsd-kind-call-signature">removeDefaultScope</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">scopeName</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">AllDefaultScopeNames</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#removedefaultscope-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Prevents a specific default scope from applying when
|
|
554
585
|
the Query is executed</p>
|
|
555
586
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">scopeName</span>: <span class="tsd-signature-type">AllDefaultScopeNames</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><p>A new Query which will prevent a specific default scope from applying</p>
|
|
556
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
587
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1201">src/dream/Query.ts:1201</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member tsd-is-protected"><h3 class="tsd-anchor-link" id="removedefaultscopeexceptonassociations"><code class="tsd-tag">Protected</code><span>remove<wbr/>Default<wbr/>Scope<wbr/>Except<wbr/>On<wbr/>Associations</span><a href="#removedefaultscopeexceptonassociations" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures tsd-is-protected"><li class=""><div class="tsd-signature tsd-anchor-link" id="removedefaultscopeexceptonassociations-1"><span class="tsd-kind-call-signature">removeDefaultScopeExceptOnAssociations</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">scopeName</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">DefaultScopeName</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#removedefaultscopeexceptonassociations-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Prevents a specific default scope from applying when
|
|
557
588
|
the Query is executed, but not when applying to asociations</p>
|
|
558
589
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">scopeName</span>: <span class="tsd-signature-type">DefaultScopeName</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></span></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><p>A new Query which will prevent a specific default scope from applying, but not when applying to asociations</p>
|
|
559
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
590
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1216">src/dream/Query.ts:1216</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="scrollpaginate"><span class="deprecated">scroll<wbr/>Paginate</span><a href="#scrollpaginate" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="scrollpaginate-1"><span class="tsd-kind-call-signature">scrollPaginate</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#scrollpaginateq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#scrollpaginateincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">this</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#scrollpaginateq">Q</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">opts</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#scrollpaginateincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"scrollPaginate is incompatible with limit, offset, and leftJoinPreload"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">CursorPaginatedDreamQueryOptions</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">CursorPaginatedDreamQueryResult</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span><a href="#scrollpaginate-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="scrollpaginateq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span></span></li><li><span id="scrollpaginateincompatible"><span class="tsd-kind-type-parameter">Incompatible</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">boolean</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">this</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#scrollpaginateq">Q</a></span></li><li><span><span class="tsd-kind-parameter">opts</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#scrollpaginateincompatible">Incompatible</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">"scrollPaginate is incompatible with limit, offset, and leftJoinPreload"</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">CursorPaginatedDreamQueryOptions</span></span><div class="tsd-comment tsd-typography"><p>scroll pagination options</p>
|
|
560
591
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">CursorPaginatedDreamQueryResult</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span></h4><p>results.cursor - identifier for the next page, or null if no more pages</p>
|
|
561
592
|
<div class="tsd-comment tsd-typography"><div class="tsd-tag-deprecated"><h4 class="tsd-anchor-link" id="deprecated">Deprecated<a href="#deprecated" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>Use <a href="#cursorpaginate" class="tsd-kind-method">cursorPaginate</a> instead.</p>
|
|
562
593
|
<p>Paginates the results of your query using cursor-based pagination,
|
|
@@ -569,19 +600,19 @@ then the implicit primary key ordering will be omitted.</p>
|
|
|
569
600
|
<pre><code class="ts"><span class="hl-7">// First page (using undefined to start from beginning)</span><br/><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">firstPage</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">order</span><span class="hl-1">(</span><span class="hl-6">'email'</span><span class="hl-1">).</span><span class="hl-5">scrollPaginate</span><span class="hl-1">({ </span><span class="hl-4">pageSize:</span><span class="hl-1"> </span><span class="hl-8">100</span><span class="hl-1">, </span><span class="hl-4">cursor:</span><span class="hl-1"> </span><span class="hl-0">undefined</span><span class="hl-1"> })</span><br/><span class="hl-4">firstPage</span><span class="hl-1">.</span><span class="hl-4">results</span><br/><span class="hl-7">// [ { User{id: 1}, User{id: 2}, ...}]</span><br/><br/><span class="hl-4">firstPage</span><span class="hl-1">.</span><span class="hl-4">cursor</span><br/><span class="hl-7">// "100" (or null if no more pages)</span><br/><br/><span class="hl-7">// Next page using cursor from previous result</span><br/><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">nextPage</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">order</span><span class="hl-1">(</span><span class="hl-6">'email'</span><span class="hl-1">).</span><span class="hl-5">scrollPaginate</span><span class="hl-1">({</span><br/><span class="hl-1"> </span><span class="hl-4">pageSize:</span><span class="hl-1"> </span><span class="hl-8">100</span><span class="hl-1">,</span><br/><span class="hl-1"> </span><span class="hl-4">cursor:</span><span class="hl-1"> </span><span class="hl-4">firstPage</span><span class="hl-1">.</span><span class="hl-4">cursor</span><br/><span class="hl-1">})</span>
|
|
570
601
|
</code><button type="button">Copy</button></pre>
|
|
571
602
|
|
|
572
|
-
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
603
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2241">src/dream/Query.ts:2241</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="sql"><span>sql</span><a href="#sql" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="sql-1"><span class="tsd-kind-call-signature">sql</span><span class="tsd-signature-symbol">()</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">CompiledQuery</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">></span><a href="#sql-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Returns the sql that would be executed by this Query</p>
|
|
573
604
|
<pre><code class="ts"><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-6">'how@yadoin'</span><span class="hl-1"> }).</span><span class="hl-5">sql</span><span class="hl-1">()</span><br/><span class="hl-7">// {</span><br/><span class="hl-7">// query: {</span><br/><span class="hl-7">// kind: 'SelectQueryNode',</span><br/><span class="hl-7">// from: { kind: 'FromNode', froms: [Array] },</span><br/><span class="hl-7">// selections: [ [Object] ],</span><br/><span class="hl-7">// distinctOn: undefined,</span><br/><span class="hl-7">// joins: undefined,</span><br/><span class="hl-7">// groupBy: undefined,</span><br/><span class="hl-7">// orderBy: undefined,</span><br/><span class="hl-7">// where: { kind: 'WhereNode', where: [Object] },</span><br/><span class="hl-7">// frontModifiers: undefined,</span><br/><span class="hl-7">// endModifiers: undefined,</span><br/><span class="hl-7">// limit: undefined,</span><br/><span class="hl-7">// offset: undefined,</span><br/><span class="hl-7">// with: undefined,</span><br/><span class="hl-7">// having: undefined,</span><br/><span class="hl-7">// explain: undefined,</span><br/><span class="hl-7">// setOperations: undefined</span><br/><span class="hl-7">// },</span><br/><span class="hl-7">// sql: 'select "users".* from "users" where ("users"."email" = $1 and "users"."deleted_at" is null)',</span><br/><span class="hl-7">// parameters: [ 'how@yadoin' ]</span><br/><span class="hl-7">//}</span>
|
|
574
605
|
</code><button type="button">Copy</button></pre>
|
|
575
606
|
|
|
576
607
|
</div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">CompiledQuery</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">object</span><span class="tsd-signature-symbol">></span></h4><p>An object representing the underlying sql statement</p>
|
|
577
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
608
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1519">src/dream/Query.ts:1519</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="sum"><span>sum</span><a href="#sum" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="sum-1"><span class="tsd-kind-call-signature">sum</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumdb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumcolumnname">ColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumreturntype">ReturnType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">columnName</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumcolumnname">ColumnName</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#sumreturntype">ReturnType</a><span class="tsd-signature-symbol">></span><a href="#sum-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Retrieves the sum value of the specified column
|
|
578
609
|
for this Query</p>
|
|
579
610
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">Game</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">sum</span><span class="hl-1">(</span><span class="hl-6">'score'</span><span class="hl-1">)</span><br/><span class="hl-7">// 1</span>
|
|
580
611
|
</code><button type="button">Copy</button></pre>
|
|
581
612
|
|
|
582
613
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="sumq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span id="sumdb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="sumcolumnname"><span class="tsd-kind-type-parameter">ColumnName</span></span></li><li><span id="sumreturntype"><span class="tsd-kind-type-parameter">ReturnType</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">columnName</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumcolumnname">ColumnName</a></span><div class="tsd-comment tsd-typography"><p>a column name on the model</p>
|
|
583
614
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#sumreturntype">ReturnType</a><span class="tsd-signature-symbol">></span></h4><p>the sum of the values of the specified column for this Query</p>
|
|
584
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
615
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1830">src/dream/Query.ts:1830</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="sumby"><span>sum<wbr/>By</span><a href="#sumby" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="sumby-1"><span class="tsd-kind-call-signature">sumBy</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbyq">Q</a> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbydb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbygroupcolumnname">GroupColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbyaggregatedcolumnname">AggregatedColumnName</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbygroupkey">GroupKey</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbyaggregatedtype">AggregatedType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">groupColumn</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbygroupcolumnname">GroupColumnName</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">aggregatedColumn</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbyaggregatedcolumnname">AggregatedColumnName</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbygroupkey">GroupKey</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbyaggregatedtype">AggregatedType</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span><a href="#sumby-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Retrieves the sum of the specified column within each group, keyed by
|
|
585
616
|
the value of the provided group column (a SQL <code>GROUP BY</code>).</p>
|
|
586
617
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">CompositionAsset</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">sumBy</span><span class="hl-1">(</span><span class="hl-6">'name'</span><span class="hl-1">, </span><span class="hl-6">'score'</span><span class="hl-1">)</span><br/><span class="hl-7">// Map(2) { 'primary' => 10, 'secondary' => 4 }</span>
|
|
587
618
|
</code><button type="button">Copy</button></pre>
|
|
@@ -597,61 +628,692 @@ are grouped under a real <code>null</code> key; a group whose aggregated values
|
|
|
597
628
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="sumbyq"><span class="tsd-kind-type-parameter">Q</span> <span class="tsd-signature-keyword">extends</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></span></li><li><span id="sumbydb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="sumbygroupcolumnname"><span class="tsd-kind-type-parameter">GroupColumnName</span></span></li><li><span id="sumbyaggregatedcolumnname"><span class="tsd-kind-type-parameter">AggregatedColumnName</span></span></li><li><span id="sumbygroupkey"><span class="tsd-kind-type-parameter">GroupKey</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="sumbyaggregatedtype"><span class="tsd-kind-type-parameter">AggregatedType</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">groupColumn</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbygroupcolumnname">GroupColumnName</a></span><div class="tsd-comment tsd-typography"><p>the column to group by (base or joined-association-namespaced)</p>
|
|
598
629
|
</div></li><li><span><span class="tsd-kind-parameter">aggregatedColumn</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbyaggregatedcolumnname">AggregatedColumnName</a></span><div class="tsd-comment tsd-typography"><p>the column to sum within each group</p>
|
|
599
630
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">Map</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbygroupkey">GroupKey</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#sumbyaggregatedtype">AggregatedType</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">></span></h4><p>A Map from each present group value to the sum of the aggregated column in that group</p>
|
|
600
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/276ab87aae35de8dce4d5a4e3052373f512d2717/src/dream/Query.ts#L1838">src/dream/Query.ts:1838</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="tokysely"><span>to<wbr/>Kysely</span><a href="#tokysely" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="tokysely-1"><span class="tsd-kind-call-signature">toKysely</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">"update"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"delete"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"select"</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a> <span class="tsd-signature-symbol">=</span> (<br/> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">Key</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Nullable</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">Extract</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">alias</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type tsd-kind-type-parameter">Key</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">}</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">null</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> (<br/> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">Key</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Nullable</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">Extract</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">alias</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type tsd-kind-type-parameter">Key</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">}</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><br/> )<span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">=</span> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span><br/> <span class="tsd-signature-symbol">|</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">|</span> (<br/> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><br/> )<br/> <span class="tsd-signature-symbol">|</span> (<br/> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"alias"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><br/> )<br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytokyselyreturntype">ToKyselyReturnType</a> <span class="tsd-signature-symbol">=</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">"select"</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">SelectQueryBuilder</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">"delete"</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">DeleteQueryBuilder</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">"update"</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">UpdateQueryBuilder</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">type</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytokyselyreturntype">ToKyselyReturnType</a><a href="#tokysely-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Converts the given dream class into a Kysely query, enabling
|
|
631
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1867">src/dream/Query.ts:1867</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="tokysely"><span>to<wbr/>Kysely</span><a href="#tokysely" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="tokysely-1"><span class="tsd-kind-call-signature">toKysely</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">"update"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"delete"</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"select"</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a> <span class="tsd-signature-symbol">=</span> (<br/> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">Key</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Nullable</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">Extract</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">alias</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type tsd-kind-type-parameter">Key</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">}</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">null</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> (<br/> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">Key</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Nullable</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">Extract</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">alias</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type tsd-kind-type-parameter">Key</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">}</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><br/> )<span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">=</span> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span><br/> <span class="tsd-signature-symbol">|</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">|</span> (<br/> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><br/> )<br/> <span class="tsd-signature-symbol">|</span> (<br/> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"alias"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><br/> )<br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytokyselyreturntype">ToKyselyReturnType</a> <span class="tsd-signature-symbol">=</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">"select"</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">SelectQueryBuilder</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">"delete"</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">DeleteQueryBuilder</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">"update"</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">UpdateQueryBuilder</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">type</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytokyselyreturntype">ToKyselyReturnType</a><a href="#tokysely-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Converts the given dream class into a Kysely query, enabling
|
|
601
632
|
you to build custom queries using the Kysely API</p>
|
|
602
633
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">toKysely</span><span class="hl-1">(</span><span class="hl-6">'select'</span><span class="hl-1">).</span><span class="hl-5">where</span><span class="hl-1">(</span><span class="hl-6">'email'</span><span class="hl-1">, </span><span class="hl-6">'='</span><span class="hl-1">, </span><span class="hl-6">'how@yadoin'</span><span class="hl-1">).</span><span class="hl-5">execute</span><span class="hl-1">()</span>
|
|
603
634
|
</code><button type="button">Copy</button></pre>
|
|
604
635
|
|
|
605
636
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="tokyselyquerytype"><span class="tsd-kind-type-parameter">QueryType</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">"update"</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"delete"</span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">"select"</span></span></li><li><span id="tokyselydbtype"><span class="tsd-kind-type-parameter">DbType</span> = (<br/> (<a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span>) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">Key</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Nullable</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">Extract</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">alias</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type tsd-kind-type-parameter">Key</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">}</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><br/>) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">null</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> (<br/> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">Key</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Nullable</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"DB"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">Extract</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">alias</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type tsd-kind-type-parameter">Key</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">}</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><br/> )</span></li><li><span id="tokyselytablenames"><span class="tsd-kind-type-parameter">TableNames</span> = (<a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span>) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span><br/> <span class="tsd-signature-symbol">|</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">|</span> (<br/> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><br/> )<br/> <span class="tsd-signature-symbol">|</span> (<br/> (<br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"length"</span><span class="tsd-signature-symbol">]</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">0</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">true</span><br/> <span class="tsd-signature-symbol">?</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"alias"</span><span class="tsd-signature-symbol">]</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">null</span><br/> )<br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"table"</span><span class="tsd-signature-symbol">]</span></span></li><li><span id="tokyselytokyselyreturntype"><span class="tsd-kind-type-parameter">ToKyselyReturnType</span> = <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">"select"</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">SelectQueryBuilder</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">"delete"</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">DeleteQueryBuilder</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">"update"</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">UpdateQueryBuilder</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytablenames">TableNames</a> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-keyword">keyof</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselydbtype">DbType</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-type">unknown</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">never</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">type</span>: <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselyquerytype">QueryType</a></span><div class="tsd-comment tsd-typography"><p>the type of Kysely query builder instance you would like to obtain</p>
|
|
606
637
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a class="tsd-signature-type tsd-kind-type-parameter" href="#tokyselytokyselyreturntype">ToKyselyReturnType</a></h4><p>A Kysely query. Depending on the type passed, it will return either a SelectQueryBuilder, DeleteQueryBuilder, or an UpdateQueryBuilder</p>
|
|
607
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
638
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1534">src/dream/Query.ts:1534</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="txn"><span>txn</span><a href="#txn" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="txn-1"><span class="tsd-kind-call-signature">txn</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">dreamTransaction</span><span class="tsd-signature-symbol">:</span> <a href="index.DreamTransaction.html" class="tsd-signature-type tsd-kind-class">DreamTransaction</a><span class="tsd-signature-symbol"><</span><a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#txn-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Applies transaction to the Query instance</p>
|
|
608
639
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">ApplicationModel</span><span class="hl-1">.</span><span class="hl-5">transaction</span><span class="hl-1">(</span><span class="hl-0">async</span><span class="hl-1"> </span><span class="hl-4">txn</span><span class="hl-1"> </span><span class="hl-0">=></span><span class="hl-1"> {</span><br/><span class="hl-1"> </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">txn</span><span class="hl-1">(</span><span class="hl-4">txn</span><span class="hl-1">).</span><span class="hl-5">create</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-6">'how@yadoin'</span><span class="hl-1"> })</span><br/><span class="hl-1">})</span>
|
|
609
640
|
</code><button type="button">Copy</button></pre>
|
|
610
641
|
|
|
611
642
|
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">dreamTransaction</span>: <a href="index.DreamTransaction.html" class="tsd-signature-type tsd-kind-class">DreamTransaction</a><span class="tsd-signature-symbol"><</span><a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span></span><div class="tsd-comment tsd-typography"><p>A DreamTransaction instance (usually collected by calling <code>ApplicationModel.transaction</code>)</p>
|
|
612
643
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><p>A cloned Query with the transaction applied</p>
|
|
613
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
644
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1562">src/dream/Query.ts:1562</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="undestroy"><span>undestroy</span><a href="#undestroy" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="undestroy-1"><span class="tsd-kind-call-signature">undestroy</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">cascade</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span><a href="#undestroy-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Undestroys a SoftDelete model, unsetting
|
|
614
645
|
the <code>deletedAt</code> field in the database.</p>
|
|
615
646
|
<p>If the model is not a SoftDelete model,
|
|
616
647
|
this will raise an exception.</p>
|
|
617
648
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-4">ops</span><span class="hl-1">.</span><span class="hl-5">ilike</span><span class="hl-1">(</span><span class="hl-6">'%burpcollaborator%'</span><span class="hl-1">) }).</span><span class="hl-5">undestroy</span><span class="hl-1">()</span><br/><span class="hl-7">// 12</span>
|
|
618
649
|
</code><button type="button">Copy</button></pre>
|
|
619
650
|
|
|
620
|
-
|
|
651
|
+
<p>A <code>limit</code> or <code>offset</code> on the Query cannot compose with the batch windows
|
|
652
|
+
<code>undestroy</code> iterates in — each batch re-applies the Query's conditions,
|
|
653
|
+
so the limit would be silently replaced by the batch size and the offset
|
|
654
|
+
re-applied to every window — so a limit- or offset-carrying Query throws
|
|
655
|
+
at runtime.</p>
|
|
656
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">cascade</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol"> = {}</span></span><div class="tsd-comment tsd-typography"><p>Options for undestroying the instance</p>
|
|
621
657
|
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">cascade</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>If false, skips undestroying associations marked <code>dependent: 'destroy'</code>. Defaults to true</p>
|
|
622
658
|
</div></li><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>If true, skips applying model hooks during the undestroy operation. Defaults to false</p>
|
|
623
659
|
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span></h4><p>The number of records that were removed</p>
|
|
624
|
-
<
|
|
660
|
+
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-8">Throws<a href="#throws-8" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>BatchingIncompatibleWithLimitOrOffset if the query carries a <code>limit</code> or <code>offset</code></p>
|
|
661
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2916">src/dream/Query.ts:2916</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="update"><span>update</span><a href="#update" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="update-1"><span class="tsd-kind-call-signature">update</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">cb</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">record</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=></span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">DrainOuterGeneric</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">K</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">number</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">symbol</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">UpdateType</span><span class="tsd-signature-symbol"><</span>(...)<span class="tsd-signature-symbol">[</span>(...)<span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span>(...)<span class="tsd-signature-symbol">[</span>(...)<span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type tsd-kind-type-parameter">K</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">&</span> (<br/> <a href="../types/types.DreamVirtualColumns.html" class="tsd-signature-type tsd-kind-type-alias">DreamVirtualColumns</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"schema"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><a href="../types/types.DreamVirtualColumns.html" class="tsd-signature-type tsd-kind-type-alias">DreamVirtualColumns</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">object</span><br/> ) <span class="tsd-signature-symbol">&</span> (<br/> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">UnionToIntersection</span><span class="tsd-signature-symbol"><</span><br/> (((...)<span class="tsd-signature-symbol">[</span>(...)<span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-type">string</span>) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">never</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span>) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> (<br/> ((...) <span class="tsd-signature-keyword">extends</span> (...) <span class="tsd-signature-symbol">?</span> (...) <span class="tsd-signature-symbol">:</span> (...)) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> (...) <span class="tsd-signature-symbol">&</span> (...)<br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">K</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">:</span> (...) <span class="tsd-signature-symbol">|</span> (...) <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">object</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">UnionToIntersection</span><span class="tsd-signature-symbol"><</span><br/> (((...)<span class="tsd-signature-symbol">[</span>(...)<span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-type">string</span>) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">never</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span>) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> (<br/> ((...) <span class="tsd-signature-keyword">extends</span> (...) <span class="tsd-signature-symbol">?</span> (...) <span class="tsd-signature-symbol">:</span> (...)) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> (...) <span class="tsd-signature-symbol">&</span> (...)<br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">K</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">:</span> (...) <span class="tsd-signature-symbol">|</span> (...) <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> )<span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">DrainOuterGeneric</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">K</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">number</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">symbol</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">UpdateType</span><span class="tsd-signature-symbol"><</span>(...)<span class="tsd-signature-symbol">[</span>(...)<span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">&</span> (<br/> <a href="../types/types.DreamVirtualColumns.html" class="tsd-signature-type tsd-kind-type-alias">DreamVirtualColumns</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"schema"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><a href="../types/types.DreamVirtualColumns.html" class="tsd-signature-type tsd-kind-type-alias">DreamVirtualColumns</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">object</span><br/> ) <span class="tsd-signature-symbol">&</span> (<br/> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">UnionToIntersection</span><span class="tsd-signature-symbol"><</span><br/> ((...) <span class="tsd-signature-keyword">extends</span> (...) <span class="tsd-signature-symbol">?</span> (...) <span class="tsd-signature-symbol">:</span> (...)) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> (...) <span class="tsd-signature-keyword">extends</span> (...) <span class="tsd-signature-symbol">?</span> (...) <span class="tsd-signature-symbol">:</span> (...)<span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">object</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">UnionToIntersection</span><span class="tsd-signature-symbol"><</span><br/> ((...) <span class="tsd-signature-keyword">extends</span> (...) <span class="tsd-signature-symbol">?</span> (...) <span class="tsd-signature-symbol">:</span> (...)) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> (...) <span class="tsd-signature-keyword">extends</span> (...) <span class="tsd-signature-symbol">?</span> (...) <span class="tsd-signature-symbol">:</span> (...)<span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> )<span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span><a href="#update-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Updates all records matching the Query</p>
|
|
625
662
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-4">ops</span><span class="hl-1">.</span><span class="hl-5">ilike</span><span class="hl-1">(</span><span class="hl-6">'%burpcollaborator%'</span><span class="hl-1">) }).</span><span class="hl-5">update</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-0">null</span><span class="hl-1"> })</span><br/><span class="hl-7">// 12</span>
|
|
626
663
|
</code><button type="button">Copy</button></pre>
|
|
627
664
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
665
|
+
<p>Instead of an attributes object, the first argument may be a callback
|
|
666
|
+
that derives each record's attributes from the record itself. The
|
|
667
|
+
callback (sync or async) receives each matching record and returns the
|
|
668
|
+
attributes to write for it, or <code>undefined</code> to skip it — a skipped record
|
|
669
|
+
gets no write, runs no hooks, and is not counted (a <code>null</code> return, from
|
|
670
|
+
untyped callers, is treated the same). Only the returned attributes are
|
|
671
|
+
written: the callback receives a clone of the record, so mutations made
|
|
672
|
+
directly on the received record are discarded rather than riding along
|
|
673
|
+
with the write. With a callback, the options object and its <code>lock</code> key
|
|
674
|
+
are mandatory, and <code>lock</code> is a full boolean, so every call site says out
|
|
675
|
+
loud whether the callback runs under row locks:</p>
|
|
676
|
+
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">update</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-4">user</span><span class="hl-1"> </span><span class="hl-0">=></span><span class="hl-1"> (</span><span class="hl-4">user</span><span class="hl-1">.</span><span class="hl-4">email</span><span class="hl-1">.</span><span class="hl-5">endsWith</span><span class="hl-1">(</span><span class="hl-6">'@example.com'</span><span class="hl-1">) ? { </span><span class="hl-4">name:</span><span class="hl-1"> </span><span class="hl-6">'example user'</span><span class="hl-1"> } : </span><span class="hl-0">undefined</span><span class="hl-1">),</span><br/><span class="hl-1"> { </span><span class="hl-4">lock:</span><span class="hl-1"> </span><span class="hl-0">false</span><span class="hl-1"> }</span><br/><span class="hl-1">)</span>
|
|
677
|
+
</code><button type="button">Copy</button></pre>
|
|
678
|
+
|
|
679
|
+
<p>Under <code>lock: false</code>, the callback runs once per matching record —
|
|
680
|
+
batched reads (<code>batchSize</code> defaults to 1000 here), no locks, no claim
|
|
681
|
+
step, no compare-and-set guarantee — the right shape for a derived
|
|
682
|
+
backfill where racing writers are not a concern. (On a <code>@ReplicaSafe</code>
|
|
683
|
+
model, these unlocked batch reads may come from a lagging replica,
|
|
684
|
+
feeding stale column values into the callback; use <code>lock: true</code> to
|
|
685
|
+
derive from the freshest committed state — its transactional reads pin
|
|
686
|
+
the primary.) Under <code>lock: true</code>, the callback runs once per claimed
|
|
687
|
+
record, under that record's row lock, inside the batch's transaction,
|
|
688
|
+
receiving a clone of the freshly locked read; Dream applies the returned
|
|
689
|
+
attributes to the record it holds and writes before the batch commits,
|
|
690
|
+
so there is no transaction handle for the caller to forget. (The record
|
|
691
|
+
the callback receives is not bound to the batch's transaction — see the
|
|
692
|
+
callback bullet below before touching the database from inside a
|
|
693
|
+
callback.) That makes the callback form the tool
|
|
694
|
+
for serializing writers on state a <code>WHERE</code> clause cannot express — for
|
|
695
|
+
example an <code>@Encrypted</code> column, whose ciphertext changes on every write
|
|
696
|
+
and whose plaintext has no column to compare against in the database:</p>
|
|
697
|
+
<pre><code class="ts"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">rotated</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">id:</span><span class="hl-1"> </span><span class="hl-4">userId</span><span class="hl-1"> }).</span><span class="hl-5">update</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-4">user</span><span class="hl-1"> </span><span class="hl-0">=></span><span class="hl-1"> (</span><span class="hl-4">user</span><span class="hl-1">.</span><span class="hl-4">secret</span><span class="hl-1"> === </span><span class="hl-4">expectedSecret</span><span class="hl-1"> ? { </span><span class="hl-4">secret:</span><span class="hl-1"> </span><span class="hl-4">newSecret</span><span class="hl-1"> } : </span><span class="hl-0">undefined</span><span class="hl-1">),</span><br/><span class="hl-1"> { </span><span class="hl-4">lock:</span><span class="hl-1"> </span><span class="hl-0">true</span><span class="hl-1"> }</span><br/><span class="hl-1">)</span><br/><span class="hl-7">// 1 — or 0, if a competing writer got there first (the callback saw a</span><br/><span class="hl-7">// different secret and skipped the record)</span>
|
|
698
|
+
</code><button type="button">Copy</button></pre>
|
|
699
|
+
|
|
700
|
+
<p>With a callback, the returned count is the number of records the
|
|
701
|
+
callback returned attributes for: skipped records are not counted, and
|
|
702
|
+
under <code>lock: true</code> records that lost the race never reach the callback
|
|
703
|
+
at all. (As with the attributes form, a write that turns out to be a
|
|
704
|
+
no-op still counts — the count means "the callback chose to write", not
|
|
705
|
+
"SQL was emitted".)</p>
|
|
706
|
+
<p>The <code>lock</code> option turns the update into a guarded (compare-and-set)
|
|
707
|
+
update: each record is written only if it still matches the Query at the
|
|
708
|
+
moment an exclusive row lock on it is acquired. Use it when the Query's
|
|
709
|
+
conditions are the thing being changed and a concurrent writer racing this
|
|
710
|
+
call must not have its write clobbered:</p>
|
|
711
|
+
<pre><code class="ts"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">updated</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">Order</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">status:</span><span class="hl-1"> </span><span class="hl-6">'pending'</span><span class="hl-1"> })</span><br/><span class="hl-1"> .</span><span class="hl-5">update</span><span class="hl-1">({ </span><span class="hl-4">status:</span><span class="hl-1"> </span><span class="hl-6">'processing'</span><span class="hl-1"> }, { </span><span class="hl-4">lock:</span><span class="hl-1"> </span><span class="hl-0">true</span><span class="hl-1"> })</span><br/><span class="hl-7">// 0 — someone else moved every one of them out of 'pending' first</span>
|
|
712
|
+
</code><button type="button">Copy</button></pre>
|
|
713
|
+
|
|
714
|
+
<p>With <code>lock: true</code>, records are processed in batches, and each batch runs
|
|
715
|
+
in its own transaction which first re-selects that batch's records with an
|
|
716
|
+
exclusive row lock and then updates them before committing. Because the
|
|
717
|
+
database re-checks the Query's conditions after acquiring each row lock, a
|
|
718
|
+
record a concurrent transaction has already moved out of the Query drops
|
|
719
|
+
out of the locked read and is never updated. The returned count is the
|
|
720
|
+
number of records claimed and submitted for writing, so a caller can
|
|
721
|
+
detect that it lost a race by comparing the count against what it
|
|
722
|
+
expected. (A claimed record whose write turns out to be a no-op — the
|
|
723
|
+
attributes already match, or a hook cleared every dirty attribute — still
|
|
724
|
+
counts; the count is not a guarantee that SQL was emitted per counted
|
|
725
|
+
record.)</p>
|
|
726
|
+
<p>Things to know before relying on it:</p>
|
|
727
|
+
<ul>
|
|
728
|
+
<li><strong>The guarantee is per batch, not set-wide.</strong> A run spanning more than
|
|
729
|
+
one batch can win a race in batch 1 and lose one in batch 2; nothing
|
|
730
|
+
holds the whole matched set still for the duration of the run. Sharing
|
|
731
|
+
one transaction across every batch — by threading a transaction onto the
|
|
732
|
+
Query itself, <code>Order.query().txn(txn).where({ ... }).update({ ... }, { lock: true })</code> — buys two things: the updates become all-or-nothing (a
|
|
733
|
+
rollback undoes the whole run), and the row locks taken by every batch
|
|
734
|
+
are held until you commit. It does <strong>not</strong> extend the compare-and-set to
|
|
735
|
+
the part of the set the run has not reached yet: under READ COMMITTED
|
|
736
|
+
each statement takes a fresh snapshot, so a record moved out of the
|
|
737
|
+
Query between batch 1 and batch 2 still drops out of batch 2's locked
|
|
738
|
+
read. A genuinely set-wide guarantee needs REPEATABLE READ /
|
|
739
|
+
SERIALIZABLE, or a single locking statement over the whole set.</li>
|
|
740
|
+
<li><strong>Only a transaction carried by the Query is shared.</strong> Merely wrapping
|
|
741
|
+
the call in <code>Model.transaction(...)</code> does not thread that transaction
|
|
742
|
+
onto the Query — <code>Dream.transaction</code> establishes no ambient transaction,
|
|
743
|
+
it only hands a <code>txn</code> to your callback — so each batch would open its
|
|
744
|
+
own transaction on a different pooled connection. Worse, if the
|
|
745
|
+
surrounding transaction has already written to any of the matched rows,
|
|
746
|
+
each batch's locked read blocks on locks the surrounding transaction
|
|
747
|
+
holds while that transaction awaits the update: a cycle across two
|
|
748
|
+
connections, which Postgres's deadlock detector cannot see, so it hangs
|
|
749
|
+
rather than aborting. Always pass the transaction with <code>.txn(txn)</code>.</li>
|
|
750
|
+
<li><strong>Behavior above READ COMMITTED differs.</strong> The drop-out-of-the-result
|
|
751
|
+
behavior described above is READ COMMITTED (Postgres's default). Under
|
|
752
|
+
REPEATABLE READ or SERIALIZABLE, the same race raises a serialization
|
|
753
|
+
failure instead of silently returning a lower count. Both are safe; only
|
|
754
|
+
one of them is quiet.</li>
|
|
755
|
+
<li><strong><code>batchSize</code> defaults to 10 here</strong>, not <code>findEach</code>'s 1000, and the
|
|
756
|
+
default is deliberately small. Every row in a batch stays locked for the
|
|
757
|
+
whole batch, including the time spent running each record's hooks — and,
|
|
758
|
+
on the callback form, the time spent running the Query's <code>preload</code>
|
|
759
|
+
queries, which are fetched inside the lock window (the attributes form
|
|
760
|
+
strips preloads, which it never consumes) — so an oversized batch blocks
|
|
761
|
+
unrelated writers touching those rows and surfaces as timeouts somewhere
|
|
762
|
+
else in the application, which is very hard to trace back to this
|
|
763
|
+
update. Too small a batch, by contrast, only slows down this call, which
|
|
764
|
+
you can see and fix. Lower it further for models with expensive update
|
|
765
|
+
hooks.</li>
|
|
766
|
+
<li><strong>The callback must not write to the database.</strong> The record handed to
|
|
767
|
+
the callback is not bound to the batch's transaction: a write through it
|
|
768
|
+
(e.g. <code>await record.update(...)</code>) goes out on a different pooled
|
|
769
|
+
connection and blocks on the batch's own row locks while the batch
|
|
770
|
+
transaction waits on the callback — a cycle across two connections that
|
|
771
|
+
the database's deadlock detector cannot see, so with no <code>lock_timeout</code>
|
|
772
|
+
the run hangs indefinitely and pins both connections. Reads through the
|
|
773
|
+
record (<code>reload</code>, <code>associationQuery</code>, ...) likewise run on a separate
|
|
774
|
+
connection and snapshot. Derive the attributes and return them; Dream
|
|
775
|
+
performs the write inside the batch's transaction.</li>
|
|
776
|
+
<li><strong><code>lock: false</code> can throw mid-run when racing a deleter.</strong> On the
|
|
777
|
+
unlocked paths, a matched record that a concurrent transaction destroys
|
|
778
|
+
between a batch's read and that record's write aborts the run with an
|
|
779
|
+
error: earlier batches stay committed, and no count is returned. Use
|
|
780
|
+
<code>lock: true</code> when deleters may race the update — claimed rows are held
|
|
781
|
+
under their locks until written.</li>
|
|
782
|
+
<li><strong>A <code>limit</code> or <code>offset</code> on the Query is incompatible with <code>update</code> on
|
|
783
|
+
every path.</strong> The batched paths re-apply the Query's conditions to each
|
|
784
|
+
batch window, where a limit or offset would skip or truncate rows
|
|
785
|
+
inside every window instead of bounding the run as a whole, and the
|
|
786
|
+
single-statement <code>skipHooks</code> attributes form cannot express either in
|
|
787
|
+
its SQL UPDATE. Every form throws rather than silently corrupting the
|
|
788
|
+
windows or ignoring the caller's scope.</li>
|
|
789
|
+
<li><strong>A batch waits, without bound, for whoever holds the row.</strong> The locked
|
|
790
|
+
read is a plain <code>FOR UPDATE</code>: if another transaction already holds a
|
|
791
|
+
lock on one of the batch's rows, this call blocks until that transaction
|
|
792
|
+
ends, holding its own transaction and its pooled connection open the
|
|
793
|
+
whole time. Dream sets no <code>lock_timeout</code> or <code>statement_timeout</code>, so a
|
|
794
|
+
long-running writer on the other side stalls the run indefinitely and,
|
|
795
|
+
at scale, ties up connections. If that is a risk in your application,
|
|
796
|
+
set a <code>lock_timeout</code> on the connection so a stuck batch fails instead of
|
|
797
|
+
hanging.</li>
|
|
798
|
+
<li><strong><code>skipHooks</code> composes with <code>lock</code>, but stays on the per-instance
|
|
799
|
+
path.</strong> With an attributes object and no <code>lock</code>, <code>skipHooks: true</code>
|
|
800
|
+
issues a single <code>UPDATE ... WHERE</code> statement that writes raw columns.
|
|
801
|
+
With <code>lock: true</code>, <code>skipHooks: true</code> skips the model hooks on each
|
|
802
|
+
claimed record but still writes through the instance, so custom setters
|
|
803
|
+
— including the setters encrypted attributes encrypt through — run as
|
|
804
|
+
they would for a plain instance update. (Virtual attributes whose
|
|
805
|
+
processing lives in a hook are still skipped, exactly as in an instance
|
|
806
|
+
update with <code>skipHooks</code>.) A callback never takes the single-statement
|
|
807
|
+
path: <code>skipHooks</code> beside a callback only skips the hooks on each
|
|
808
|
+
per-record write, under <code>lock: true</code> and <code>lock: false</code> alike.</li>
|
|
809
|
+
<li><strong>If you are updating a large set and do not need compare-and-set, do
|
|
810
|
+
not pass <code>lock</code>.</strong> Plain <code>update(attributes)</code> (hooks, no locking) or
|
|
811
|
+
<code>update(attributes, { skipHooks: true })</code> (a single statement, no hooks)
|
|
812
|
+
are the right tools for bulk updates.</li>
|
|
813
|
+
</ul>
|
|
814
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">cb</span>: <span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">record</span><span class="tsd-signature-symbol">:</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span> <span class="tsd-signature-symbol">=></span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">DrainOuterGeneric</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span><br/> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">K</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">number</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">symbol</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">UpdateType</span><span class="tsd-signature-symbol"><</span>(...)<span class="tsd-signature-symbol">[</span>(...)<span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span>(...)<span class="tsd-signature-symbol">[</span>(...)<span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type tsd-kind-type-parameter">K</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">&</span> (<br/> <a href="../types/types.DreamVirtualColumns.html" class="tsd-signature-type tsd-kind-type-alias">DreamVirtualColumns</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"schema"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><a href="../types/types.DreamVirtualColumns.html" class="tsd-signature-type tsd-kind-type-alias">DreamVirtualColumns</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">object</span><br/> ) <span class="tsd-signature-symbol">&</span> (<br/> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">UnionToIntersection</span><span class="tsd-signature-symbol"><</span><br/> (((...)<span class="tsd-signature-symbol">[</span>(...)<span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-type">string</span>) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">never</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span>) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> (<br/> ((...) <span class="tsd-signature-keyword">extends</span> (...) <span class="tsd-signature-symbol">?</span> (...) <span class="tsd-signature-symbol">:</span> (...)) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> (...) <span class="tsd-signature-symbol">&</span> (...)<br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">K</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">:</span> (...) <span class="tsd-signature-symbol">|</span> (...) <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">object</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">UnionToIntersection</span><span class="tsd-signature-symbol"><</span><br/> (((...)<span class="tsd-signature-symbol">[</span>(...)<span class="tsd-signature-symbol">]</span> <span class="tsd-signature-symbol">&</span> <span class="tsd-signature-type">string</span>) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">never</span> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">false</span> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span>) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> (<br/> ((...) <span class="tsd-signature-keyword">extends</span> (...) <span class="tsd-signature-symbol">?</span> (...) <span class="tsd-signature-symbol">:</span> (...)) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> (...) <span class="tsd-signature-symbol">&</span> (...)<br/> ) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">K</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">:</span> (...) <span class="tsd-signature-symbol">|</span> (...) <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> )<span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">DrainOuterGeneric</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-symbol">{</span> <span class="tsd-signature-symbol">[</span><span class="tsd-kind-type-parameter">K</span> <span class="tsd-signature-keyword">in</span> <span class="tsd-signature-type">string</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">number</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">symbol</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">UpdateType</span><span class="tsd-signature-symbol"><</span>(...)<span class="tsd-signature-symbol">[</span>(...)<span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span> <span class="tsd-signature-symbol">&</span> (<br/> <a href="../types/types.DreamVirtualColumns.html" class="tsd-signature-type tsd-kind-type-alias">DreamVirtualColumns</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"schema"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">></span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-keyword">readonly</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">Record</span><span class="tsd-signature-symbol"><</span><a href="../types/types.DreamVirtualColumns.html" class="tsd-signature-type tsd-kind-type-alias">DreamVirtualColumns</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">object</span><br/> ) <span class="tsd-signature-symbol">&</span> (<br/> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">UnionToIntersection</span><span class="tsd-signature-symbol"><</span><br/> ((...) <span class="tsd-signature-keyword">extends</span> (...) <span class="tsd-signature-symbol">?</span> (...) <span class="tsd-signature-symbol">:</span> (...)) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> (...) <span class="tsd-signature-keyword">extends</span> (...) <span class="tsd-signature-symbol">?</span> (...) <span class="tsd-signature-symbol">:</span> (...)<span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">object</span><br/> <span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Partial</span><span class="tsd-signature-symbol"><</span><br/> <span class="tsd-signature-type">UnionToIntersection</span><span class="tsd-signature-symbol"><</span><br/> ((...) <span class="tsd-signature-keyword">extends</span> (...) <span class="tsd-signature-symbol">?</span> (...) <span class="tsd-signature-symbol">:</span> (...)) <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">false</span><br/> <span class="tsd-signature-symbol">?</span> <span class="tsd-signature-type">never</span><br/> <span class="tsd-signature-symbol">:</span> (...) <span class="tsd-signature-keyword">extends</span> (...) <span class="tsd-signature-symbol">?</span> (...) <span class="tsd-signature-symbol">:</span> (...)<span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> )<span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">undefined</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">undefined</span></span></li><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">boolean</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">}</span></span><div class="tsd-comment tsd-typography"><p>Options for updating the instance</p>
|
|
815
|
+
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><p>The number of records to process per batch. Must be a positive integer. Defaults to 10 when <code>lock</code> is true, and to 1000 for the unlocked callback form</p>
|
|
816
|
+
</div></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>If true, each batch is re-selected with an exclusive row lock inside its own transaction before being updated, making the update a compare-and-set. Defaults to false for the attributes form; with a callback there is no default — an explicit boolean is required. One typing asymmetry to know: with an attributes object, an explicit <code>lock: false</code> keeps the raw single-statement (<code>DreamTableSchema</code>) typing that <code>skipHooks</code> uses, so virtual/encrypted attributes type-check only when the options object is omitted entirely or <code>lock</code> is <code>true</code></p>
|
|
817
|
+
</div></li><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>If true, skips applying model hooks. Defaults to false</p>
|
|
818
|
+
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span></h4><p>The number of records that were updated</p>
|
|
819
|
+
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-9">Throws<a href="#throws-9" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>InvalidBatchSize if <code>batchSize</code> is not a positive integer</p>
|
|
820
|
+
</div><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-10">Throws<a href="#throws-10" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>MissingRequiredLockOptionForUpdateCallback if a callback is passed without an options object carrying a boolean <code>lock</code></p>
|
|
821
|
+
</div><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-11">Throws<a href="#throws-11" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>BatchingIncompatibleWithLimitOrOffset if the query carries a <code>limit</code> or <code>offset</code></p>
|
|
822
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L3151">src/dream/Query.ts:3151</a></li></ul></aside></div></li><li class=""><div class="tsd-signature tsd-anchor-link" id="update-2"><span class="tsd-kind-call-signature">update</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">attributes</span><span class="tsd-signature-symbol">:</span> <a href="../types/types.UpdateableProperties.html" class="tsd-signature-type tsd-kind-type-alias">UpdateableProperties</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span><a href="#update-2" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Updates all records matching the Query</p>
|
|
823
|
+
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-4">ops</span><span class="hl-1">.</span><span class="hl-5">ilike</span><span class="hl-1">(</span><span class="hl-6">'%burpcollaborator%'</span><span class="hl-1">) }).</span><span class="hl-5">update</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-0">null</span><span class="hl-1"> })</span><br/><span class="hl-7">// 12</span>
|
|
824
|
+
</code><button type="button">Copy</button></pre>
|
|
825
|
+
|
|
826
|
+
<p>Instead of an attributes object, the first argument may be a callback
|
|
827
|
+
that derives each record's attributes from the record itself. The
|
|
828
|
+
callback (sync or async) receives each matching record and returns the
|
|
829
|
+
attributes to write for it, or <code>undefined</code> to skip it — a skipped record
|
|
830
|
+
gets no write, runs no hooks, and is not counted (a <code>null</code> return, from
|
|
831
|
+
untyped callers, is treated the same). Only the returned attributes are
|
|
832
|
+
written: the callback receives a clone of the record, so mutations made
|
|
833
|
+
directly on the received record are discarded rather than riding along
|
|
834
|
+
with the write. With a callback, the options object and its <code>lock</code> key
|
|
835
|
+
are mandatory, and <code>lock</code> is a full boolean, so every call site says out
|
|
836
|
+
loud whether the callback runs under row locks:</p>
|
|
837
|
+
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">update</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-4">user</span><span class="hl-1"> </span><span class="hl-0">=></span><span class="hl-1"> (</span><span class="hl-4">user</span><span class="hl-1">.</span><span class="hl-4">email</span><span class="hl-1">.</span><span class="hl-5">endsWith</span><span class="hl-1">(</span><span class="hl-6">'@example.com'</span><span class="hl-1">) ? { </span><span class="hl-4">name:</span><span class="hl-1"> </span><span class="hl-6">'example user'</span><span class="hl-1"> } : </span><span class="hl-0">undefined</span><span class="hl-1">),</span><br/><span class="hl-1"> { </span><span class="hl-4">lock:</span><span class="hl-1"> </span><span class="hl-0">false</span><span class="hl-1"> }</span><br/><span class="hl-1">)</span>
|
|
838
|
+
</code><button type="button">Copy</button></pre>
|
|
839
|
+
|
|
840
|
+
<p>Under <code>lock: false</code>, the callback runs once per matching record —
|
|
841
|
+
batched reads (<code>batchSize</code> defaults to 1000 here), no locks, no claim
|
|
842
|
+
step, no compare-and-set guarantee — the right shape for a derived
|
|
843
|
+
backfill where racing writers are not a concern. (On a <code>@ReplicaSafe</code>
|
|
844
|
+
model, these unlocked batch reads may come from a lagging replica,
|
|
845
|
+
feeding stale column values into the callback; use <code>lock: true</code> to
|
|
846
|
+
derive from the freshest committed state — its transactional reads pin
|
|
847
|
+
the primary.) Under <code>lock: true</code>, the callback runs once per claimed
|
|
848
|
+
record, under that record's row lock, inside the batch's transaction,
|
|
849
|
+
receiving a clone of the freshly locked read; Dream applies the returned
|
|
850
|
+
attributes to the record it holds and writes before the batch commits,
|
|
851
|
+
so there is no transaction handle for the caller to forget. (The record
|
|
852
|
+
the callback receives is not bound to the batch's transaction — see the
|
|
853
|
+
callback bullet below before touching the database from inside a
|
|
854
|
+
callback.) That makes the callback form the tool
|
|
855
|
+
for serializing writers on state a <code>WHERE</code> clause cannot express — for
|
|
856
|
+
example an <code>@Encrypted</code> column, whose ciphertext changes on every write
|
|
857
|
+
and whose plaintext has no column to compare against in the database:</p>
|
|
858
|
+
<pre><code class="ts"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">rotated</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">id:</span><span class="hl-1"> </span><span class="hl-4">userId</span><span class="hl-1"> }).</span><span class="hl-5">update</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-4">user</span><span class="hl-1"> </span><span class="hl-0">=></span><span class="hl-1"> (</span><span class="hl-4">user</span><span class="hl-1">.</span><span class="hl-4">secret</span><span class="hl-1"> === </span><span class="hl-4">expectedSecret</span><span class="hl-1"> ? { </span><span class="hl-4">secret:</span><span class="hl-1"> </span><span class="hl-4">newSecret</span><span class="hl-1"> } : </span><span class="hl-0">undefined</span><span class="hl-1">),</span><br/><span class="hl-1"> { </span><span class="hl-4">lock:</span><span class="hl-1"> </span><span class="hl-0">true</span><span class="hl-1"> }</span><br/><span class="hl-1">)</span><br/><span class="hl-7">// 1 — or 0, if a competing writer got there first (the callback saw a</span><br/><span class="hl-7">// different secret and skipped the record)</span>
|
|
859
|
+
</code><button type="button">Copy</button></pre>
|
|
860
|
+
|
|
861
|
+
<p>With a callback, the returned count is the number of records the
|
|
862
|
+
callback returned attributes for: skipped records are not counted, and
|
|
863
|
+
under <code>lock: true</code> records that lost the race never reach the callback
|
|
864
|
+
at all. (As with the attributes form, a write that turns out to be a
|
|
865
|
+
no-op still counts — the count means "the callback chose to write", not
|
|
866
|
+
"SQL was emitted".)</p>
|
|
867
|
+
<p>The <code>lock</code> option turns the update into a guarded (compare-and-set)
|
|
868
|
+
update: each record is written only if it still matches the Query at the
|
|
869
|
+
moment an exclusive row lock on it is acquired. Use it when the Query's
|
|
870
|
+
conditions are the thing being changed and a concurrent writer racing this
|
|
871
|
+
call must not have its write clobbered:</p>
|
|
872
|
+
<pre><code class="ts"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">updated</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">Order</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">status:</span><span class="hl-1"> </span><span class="hl-6">'pending'</span><span class="hl-1"> })</span><br/><span class="hl-1"> .</span><span class="hl-5">update</span><span class="hl-1">({ </span><span class="hl-4">status:</span><span class="hl-1"> </span><span class="hl-6">'processing'</span><span class="hl-1"> }, { </span><span class="hl-4">lock:</span><span class="hl-1"> </span><span class="hl-0">true</span><span class="hl-1"> })</span><br/><span class="hl-7">// 0 — someone else moved every one of them out of 'pending' first</span>
|
|
873
|
+
</code><button type="button">Copy</button></pre>
|
|
874
|
+
|
|
875
|
+
<p>With <code>lock: true</code>, records are processed in batches, and each batch runs
|
|
876
|
+
in its own transaction which first re-selects that batch's records with an
|
|
877
|
+
exclusive row lock and then updates them before committing. Because the
|
|
878
|
+
database re-checks the Query's conditions after acquiring each row lock, a
|
|
879
|
+
record a concurrent transaction has already moved out of the Query drops
|
|
880
|
+
out of the locked read and is never updated. The returned count is the
|
|
881
|
+
number of records claimed and submitted for writing, so a caller can
|
|
882
|
+
detect that it lost a race by comparing the count against what it
|
|
883
|
+
expected. (A claimed record whose write turns out to be a no-op — the
|
|
884
|
+
attributes already match, or a hook cleared every dirty attribute — still
|
|
885
|
+
counts; the count is not a guarantee that SQL was emitted per counted
|
|
886
|
+
record.)</p>
|
|
887
|
+
<p>Things to know before relying on it:</p>
|
|
888
|
+
<ul>
|
|
889
|
+
<li><strong>The guarantee is per batch, not set-wide.</strong> A run spanning more than
|
|
890
|
+
one batch can win a race in batch 1 and lose one in batch 2; nothing
|
|
891
|
+
holds the whole matched set still for the duration of the run. Sharing
|
|
892
|
+
one transaction across every batch — by threading a transaction onto the
|
|
893
|
+
Query itself, <code>Order.query().txn(txn).where({ ... }).update({ ... }, { lock: true })</code> — buys two things: the updates become all-or-nothing (a
|
|
894
|
+
rollback undoes the whole run), and the row locks taken by every batch
|
|
895
|
+
are held until you commit. It does <strong>not</strong> extend the compare-and-set to
|
|
896
|
+
the part of the set the run has not reached yet: under READ COMMITTED
|
|
897
|
+
each statement takes a fresh snapshot, so a record moved out of the
|
|
898
|
+
Query between batch 1 and batch 2 still drops out of batch 2's locked
|
|
899
|
+
read. A genuinely set-wide guarantee needs REPEATABLE READ /
|
|
900
|
+
SERIALIZABLE, or a single locking statement over the whole set.</li>
|
|
901
|
+
<li><strong>Only a transaction carried by the Query is shared.</strong> Merely wrapping
|
|
902
|
+
the call in <code>Model.transaction(...)</code> does not thread that transaction
|
|
903
|
+
onto the Query — <code>Dream.transaction</code> establishes no ambient transaction,
|
|
904
|
+
it only hands a <code>txn</code> to your callback — so each batch would open its
|
|
905
|
+
own transaction on a different pooled connection. Worse, if the
|
|
906
|
+
surrounding transaction has already written to any of the matched rows,
|
|
907
|
+
each batch's locked read blocks on locks the surrounding transaction
|
|
908
|
+
holds while that transaction awaits the update: a cycle across two
|
|
909
|
+
connections, which Postgres's deadlock detector cannot see, so it hangs
|
|
910
|
+
rather than aborting. Always pass the transaction with <code>.txn(txn)</code>.</li>
|
|
911
|
+
<li><strong>Behavior above READ COMMITTED differs.</strong> The drop-out-of-the-result
|
|
912
|
+
behavior described above is READ COMMITTED (Postgres's default). Under
|
|
913
|
+
REPEATABLE READ or SERIALIZABLE, the same race raises a serialization
|
|
914
|
+
failure instead of silently returning a lower count. Both are safe; only
|
|
915
|
+
one of them is quiet.</li>
|
|
916
|
+
<li><strong><code>batchSize</code> defaults to 10 here</strong>, not <code>findEach</code>'s 1000, and the
|
|
917
|
+
default is deliberately small. Every row in a batch stays locked for the
|
|
918
|
+
whole batch, including the time spent running each record's hooks — and,
|
|
919
|
+
on the callback form, the time spent running the Query's <code>preload</code>
|
|
920
|
+
queries, which are fetched inside the lock window (the attributes form
|
|
921
|
+
strips preloads, which it never consumes) — so an oversized batch blocks
|
|
922
|
+
unrelated writers touching those rows and surfaces as timeouts somewhere
|
|
923
|
+
else in the application, which is very hard to trace back to this
|
|
924
|
+
update. Too small a batch, by contrast, only slows down this call, which
|
|
925
|
+
you can see and fix. Lower it further for models with expensive update
|
|
926
|
+
hooks.</li>
|
|
927
|
+
<li><strong>The callback must not write to the database.</strong> The record handed to
|
|
928
|
+
the callback is not bound to the batch's transaction: a write through it
|
|
929
|
+
(e.g. <code>await record.update(...)</code>) goes out on a different pooled
|
|
930
|
+
connection and blocks on the batch's own row locks while the batch
|
|
931
|
+
transaction waits on the callback — a cycle across two connections that
|
|
932
|
+
the database's deadlock detector cannot see, so with no <code>lock_timeout</code>
|
|
933
|
+
the run hangs indefinitely and pins both connections. Reads through the
|
|
934
|
+
record (<code>reload</code>, <code>associationQuery</code>, ...) likewise run on a separate
|
|
935
|
+
connection and snapshot. Derive the attributes and return them; Dream
|
|
936
|
+
performs the write inside the batch's transaction.</li>
|
|
937
|
+
<li><strong><code>lock: false</code> can throw mid-run when racing a deleter.</strong> On the
|
|
938
|
+
unlocked paths, a matched record that a concurrent transaction destroys
|
|
939
|
+
between a batch's read and that record's write aborts the run with an
|
|
940
|
+
error: earlier batches stay committed, and no count is returned. Use
|
|
941
|
+
<code>lock: true</code> when deleters may race the update — claimed rows are held
|
|
942
|
+
under their locks until written.</li>
|
|
943
|
+
<li><strong>A <code>limit</code> or <code>offset</code> on the Query is incompatible with <code>update</code> on
|
|
944
|
+
every path.</strong> The batched paths re-apply the Query's conditions to each
|
|
945
|
+
batch window, where a limit or offset would skip or truncate rows
|
|
946
|
+
inside every window instead of bounding the run as a whole, and the
|
|
947
|
+
single-statement <code>skipHooks</code> attributes form cannot express either in
|
|
948
|
+
its SQL UPDATE. Every form throws rather than silently corrupting the
|
|
949
|
+
windows or ignoring the caller's scope.</li>
|
|
950
|
+
<li><strong>A batch waits, without bound, for whoever holds the row.</strong> The locked
|
|
951
|
+
read is a plain <code>FOR UPDATE</code>: if another transaction already holds a
|
|
952
|
+
lock on one of the batch's rows, this call blocks until that transaction
|
|
953
|
+
ends, holding its own transaction and its pooled connection open the
|
|
954
|
+
whole time. Dream sets no <code>lock_timeout</code> or <code>statement_timeout</code>, so a
|
|
955
|
+
long-running writer on the other side stalls the run indefinitely and,
|
|
956
|
+
at scale, ties up connections. If that is a risk in your application,
|
|
957
|
+
set a <code>lock_timeout</code> on the connection so a stuck batch fails instead of
|
|
958
|
+
hanging.</li>
|
|
959
|
+
<li><strong><code>skipHooks</code> composes with <code>lock</code>, but stays on the per-instance
|
|
960
|
+
path.</strong> With an attributes object and no <code>lock</code>, <code>skipHooks: true</code>
|
|
961
|
+
issues a single <code>UPDATE ... WHERE</code> statement that writes raw columns.
|
|
962
|
+
With <code>lock: true</code>, <code>skipHooks: true</code> skips the model hooks on each
|
|
963
|
+
claimed record but still writes through the instance, so custom setters
|
|
964
|
+
— including the setters encrypted attributes encrypt through — run as
|
|
965
|
+
they would for a plain instance update. (Virtual attributes whose
|
|
966
|
+
processing lives in a hook are still skipped, exactly as in an instance
|
|
967
|
+
update with <code>skipHooks</code>.) A callback never takes the single-statement
|
|
968
|
+
path: <code>skipHooks</code> beside a callback only skips the hooks on each
|
|
969
|
+
per-record write, under <code>lock: true</code> and <code>lock: false</code> alike.</li>
|
|
970
|
+
<li><strong>If you are updating a large set and do not need compare-and-set, do
|
|
971
|
+
not pass <code>lock</code>.</strong> Plain <code>update(attributes)</code> (hooks, no locking) or
|
|
972
|
+
<code>update(attributes, { skipHooks: true })</code> (a single statement, no hooks)
|
|
973
|
+
are the right tools for bulk updates.</li>
|
|
974
|
+
</ul>
|
|
975
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">attributes</span>: <a href="../types/types.UpdateableProperties.html" class="tsd-signature-type tsd-kind-type-alias">UpdateableProperties</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></span></li><li><span><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">true</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">}</span></span><div class="tsd-comment tsd-typography"><p>Options for updating the instance</p>
|
|
976
|
+
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">batchSize</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><p>The number of records to process per batch. Must be a positive integer. Defaults to 10 when <code>lock</code> is true, and to 1000 for the unlocked callback form</p>
|
|
977
|
+
</div></li><li class="tsd-parameter"><h5><span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">true</span></h5><div class="tsd-comment tsd-typography"><p>If true, each batch is re-selected with an exclusive row lock inside its own transaction before being updated, making the update a compare-and-set. Defaults to false for the attributes form; with a callback there is no default — an explicit boolean is required. One typing asymmetry to know: with an attributes object, an explicit <code>lock: false</code> keeps the raw single-statement (<code>DreamTableSchema</code>) typing that <code>skipHooks</code> uses, so virtual/encrypted attributes type-check only when the options object is omitted entirely or <code>lock</code> is <code>true</code></p>
|
|
978
|
+
</div></li><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>If true, skips applying model hooks. Defaults to false</p>
|
|
631
979
|
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span></h4><p>The number of records that were updated</p>
|
|
632
|
-
<
|
|
980
|
+
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-12">Throws<a href="#throws-12" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>InvalidBatchSize if <code>batchSize</code> is not a positive integer</p>
|
|
981
|
+
</div><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-13">Throws<a href="#throws-13" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>MissingRequiredLockOptionForUpdateCallback if a callback is passed without an options object carrying a boolean <code>lock</code></p>
|
|
982
|
+
</div><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-14">Throws<a href="#throws-14" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>BatchingIncompatibleWithLimitOrOffset if the query carries a <code>limit</code> or <code>offset</code></p>
|
|
983
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L3160">src/dream/Query.ts:3160</a></li></ul></aside></div></li><li class=""><div class="tsd-signature tsd-anchor-link" id="update-3"><span class="tsd-kind-call-signature">update</span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">attributes</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">DreamTableSchema</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-kind-parameter">options</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">}</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span><a href="#update-3" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Updates all records matching the Query</p>
|
|
633
984
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-4">ops</span><span class="hl-1">.</span><span class="hl-5">ilike</span><span class="hl-1">(</span><span class="hl-6">'%burpcollaborator%'</span><span class="hl-1">) }).</span><span class="hl-5">update</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-0">null</span><span class="hl-1"> })</span><br/><span class="hl-7">// 12</span>
|
|
634
985
|
</code><button type="button">Copy</button></pre>
|
|
635
986
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
987
|
+
<p>Instead of an attributes object, the first argument may be a callback
|
|
988
|
+
that derives each record's attributes from the record itself. The
|
|
989
|
+
callback (sync or async) receives each matching record and returns the
|
|
990
|
+
attributes to write for it, or <code>undefined</code> to skip it — a skipped record
|
|
991
|
+
gets no write, runs no hooks, and is not counted (a <code>null</code> return, from
|
|
992
|
+
untyped callers, is treated the same). Only the returned attributes are
|
|
993
|
+
written: the callback receives a clone of the record, so mutations made
|
|
994
|
+
directly on the received record are discarded rather than riding along
|
|
995
|
+
with the write. With a callback, the options object and its <code>lock</code> key
|
|
996
|
+
are mandatory, and <code>lock</code> is a full boolean, so every call site says out
|
|
997
|
+
loud whether the callback runs under row locks:</p>
|
|
998
|
+
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">update</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-4">user</span><span class="hl-1"> </span><span class="hl-0">=></span><span class="hl-1"> (</span><span class="hl-4">user</span><span class="hl-1">.</span><span class="hl-4">email</span><span class="hl-1">.</span><span class="hl-5">endsWith</span><span class="hl-1">(</span><span class="hl-6">'@example.com'</span><span class="hl-1">) ? { </span><span class="hl-4">name:</span><span class="hl-1"> </span><span class="hl-6">'example user'</span><span class="hl-1"> } : </span><span class="hl-0">undefined</span><span class="hl-1">),</span><br/><span class="hl-1"> { </span><span class="hl-4">lock:</span><span class="hl-1"> </span><span class="hl-0">false</span><span class="hl-1"> }</span><br/><span class="hl-1">)</span>
|
|
999
|
+
</code><button type="button">Copy</button></pre>
|
|
1000
|
+
|
|
1001
|
+
<p>Under <code>lock: false</code>, the callback runs once per matching record —
|
|
1002
|
+
batched reads (<code>batchSize</code> defaults to 1000 here), no locks, no claim
|
|
1003
|
+
step, no compare-and-set guarantee — the right shape for a derived
|
|
1004
|
+
backfill where racing writers are not a concern. (On a <code>@ReplicaSafe</code>
|
|
1005
|
+
model, these unlocked batch reads may come from a lagging replica,
|
|
1006
|
+
feeding stale column values into the callback; use <code>lock: true</code> to
|
|
1007
|
+
derive from the freshest committed state — its transactional reads pin
|
|
1008
|
+
the primary.) Under <code>lock: true</code>, the callback runs once per claimed
|
|
1009
|
+
record, under that record's row lock, inside the batch's transaction,
|
|
1010
|
+
receiving a clone of the freshly locked read; Dream applies the returned
|
|
1011
|
+
attributes to the record it holds and writes before the batch commits,
|
|
1012
|
+
so there is no transaction handle for the caller to forget. (The record
|
|
1013
|
+
the callback receives is not bound to the batch's transaction — see the
|
|
1014
|
+
callback bullet below before touching the database from inside a
|
|
1015
|
+
callback.) That makes the callback form the tool
|
|
1016
|
+
for serializing writers on state a <code>WHERE</code> clause cannot express — for
|
|
1017
|
+
example an <code>@Encrypted</code> column, whose ciphertext changes on every write
|
|
1018
|
+
and whose plaintext has no column to compare against in the database:</p>
|
|
1019
|
+
<pre><code class="ts"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">rotated</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">id:</span><span class="hl-1"> </span><span class="hl-4">userId</span><span class="hl-1"> }).</span><span class="hl-5">update</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-4">user</span><span class="hl-1"> </span><span class="hl-0">=></span><span class="hl-1"> (</span><span class="hl-4">user</span><span class="hl-1">.</span><span class="hl-4">secret</span><span class="hl-1"> === </span><span class="hl-4">expectedSecret</span><span class="hl-1"> ? { </span><span class="hl-4">secret:</span><span class="hl-1"> </span><span class="hl-4">newSecret</span><span class="hl-1"> } : </span><span class="hl-0">undefined</span><span class="hl-1">),</span><br/><span class="hl-1"> { </span><span class="hl-4">lock:</span><span class="hl-1"> </span><span class="hl-0">true</span><span class="hl-1"> }</span><br/><span class="hl-1">)</span><br/><span class="hl-7">// 1 — or 0, if a competing writer got there first (the callback saw a</span><br/><span class="hl-7">// different secret and skipped the record)</span>
|
|
1020
|
+
</code><button type="button">Copy</button></pre>
|
|
1021
|
+
|
|
1022
|
+
<p>With a callback, the returned count is the number of records the
|
|
1023
|
+
callback returned attributes for: skipped records are not counted, and
|
|
1024
|
+
under <code>lock: true</code> records that lost the race never reach the callback
|
|
1025
|
+
at all. (As with the attributes form, a write that turns out to be a
|
|
1026
|
+
no-op still counts — the count means "the callback chose to write", not
|
|
1027
|
+
"SQL was emitted".)</p>
|
|
1028
|
+
<p>The <code>lock</code> option turns the update into a guarded (compare-and-set)
|
|
1029
|
+
update: each record is written only if it still matches the Query at the
|
|
1030
|
+
moment an exclusive row lock on it is acquired. Use it when the Query's
|
|
1031
|
+
conditions are the thing being changed and a concurrent writer racing this
|
|
1032
|
+
call must not have its write clobbered:</p>
|
|
1033
|
+
<pre><code class="ts"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">updated</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">Order</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">status:</span><span class="hl-1"> </span><span class="hl-6">'pending'</span><span class="hl-1"> })</span><br/><span class="hl-1"> .</span><span class="hl-5">update</span><span class="hl-1">({ </span><span class="hl-4">status:</span><span class="hl-1"> </span><span class="hl-6">'processing'</span><span class="hl-1"> }, { </span><span class="hl-4">lock:</span><span class="hl-1"> </span><span class="hl-0">true</span><span class="hl-1"> })</span><br/><span class="hl-7">// 0 — someone else moved every one of them out of 'pending' first</span>
|
|
1034
|
+
</code><button type="button">Copy</button></pre>
|
|
1035
|
+
|
|
1036
|
+
<p>With <code>lock: true</code>, records are processed in batches, and each batch runs
|
|
1037
|
+
in its own transaction which first re-selects that batch's records with an
|
|
1038
|
+
exclusive row lock and then updates them before committing. Because the
|
|
1039
|
+
database re-checks the Query's conditions after acquiring each row lock, a
|
|
1040
|
+
record a concurrent transaction has already moved out of the Query drops
|
|
1041
|
+
out of the locked read and is never updated. The returned count is the
|
|
1042
|
+
number of records claimed and submitted for writing, so a caller can
|
|
1043
|
+
detect that it lost a race by comparing the count against what it
|
|
1044
|
+
expected. (A claimed record whose write turns out to be a no-op — the
|
|
1045
|
+
attributes already match, or a hook cleared every dirty attribute — still
|
|
1046
|
+
counts; the count is not a guarantee that SQL was emitted per counted
|
|
1047
|
+
record.)</p>
|
|
1048
|
+
<p>Things to know before relying on it:</p>
|
|
1049
|
+
<ul>
|
|
1050
|
+
<li><strong>The guarantee is per batch, not set-wide.</strong> A run spanning more than
|
|
1051
|
+
one batch can win a race in batch 1 and lose one in batch 2; nothing
|
|
1052
|
+
holds the whole matched set still for the duration of the run. Sharing
|
|
1053
|
+
one transaction across every batch — by threading a transaction onto the
|
|
1054
|
+
Query itself, <code>Order.query().txn(txn).where({ ... }).update({ ... }, { lock: true })</code> — buys two things: the updates become all-or-nothing (a
|
|
1055
|
+
rollback undoes the whole run), and the row locks taken by every batch
|
|
1056
|
+
are held until you commit. It does <strong>not</strong> extend the compare-and-set to
|
|
1057
|
+
the part of the set the run has not reached yet: under READ COMMITTED
|
|
1058
|
+
each statement takes a fresh snapshot, so a record moved out of the
|
|
1059
|
+
Query between batch 1 and batch 2 still drops out of batch 2's locked
|
|
1060
|
+
read. A genuinely set-wide guarantee needs REPEATABLE READ /
|
|
1061
|
+
SERIALIZABLE, or a single locking statement over the whole set.</li>
|
|
1062
|
+
<li><strong>Only a transaction carried by the Query is shared.</strong> Merely wrapping
|
|
1063
|
+
the call in <code>Model.transaction(...)</code> does not thread that transaction
|
|
1064
|
+
onto the Query — <code>Dream.transaction</code> establishes no ambient transaction,
|
|
1065
|
+
it only hands a <code>txn</code> to your callback — so each batch would open its
|
|
1066
|
+
own transaction on a different pooled connection. Worse, if the
|
|
1067
|
+
surrounding transaction has already written to any of the matched rows,
|
|
1068
|
+
each batch's locked read blocks on locks the surrounding transaction
|
|
1069
|
+
holds while that transaction awaits the update: a cycle across two
|
|
1070
|
+
connections, which Postgres's deadlock detector cannot see, so it hangs
|
|
1071
|
+
rather than aborting. Always pass the transaction with <code>.txn(txn)</code>.</li>
|
|
1072
|
+
<li><strong>Behavior above READ COMMITTED differs.</strong> The drop-out-of-the-result
|
|
1073
|
+
behavior described above is READ COMMITTED (Postgres's default). Under
|
|
1074
|
+
REPEATABLE READ or SERIALIZABLE, the same race raises a serialization
|
|
1075
|
+
failure instead of silently returning a lower count. Both are safe; only
|
|
1076
|
+
one of them is quiet.</li>
|
|
1077
|
+
<li><strong><code>batchSize</code> defaults to 10 here</strong>, not <code>findEach</code>'s 1000, and the
|
|
1078
|
+
default is deliberately small. Every row in a batch stays locked for the
|
|
1079
|
+
whole batch, including the time spent running each record's hooks — and,
|
|
1080
|
+
on the callback form, the time spent running the Query's <code>preload</code>
|
|
1081
|
+
queries, which are fetched inside the lock window (the attributes form
|
|
1082
|
+
strips preloads, which it never consumes) — so an oversized batch blocks
|
|
1083
|
+
unrelated writers touching those rows and surfaces as timeouts somewhere
|
|
1084
|
+
else in the application, which is very hard to trace back to this
|
|
1085
|
+
update. Too small a batch, by contrast, only slows down this call, which
|
|
1086
|
+
you can see and fix. Lower it further for models with expensive update
|
|
1087
|
+
hooks.</li>
|
|
1088
|
+
<li><strong>The callback must not write to the database.</strong> The record handed to
|
|
1089
|
+
the callback is not bound to the batch's transaction: a write through it
|
|
1090
|
+
(e.g. <code>await record.update(...)</code>) goes out on a different pooled
|
|
1091
|
+
connection and blocks on the batch's own row locks while the batch
|
|
1092
|
+
transaction waits on the callback — a cycle across two connections that
|
|
1093
|
+
the database's deadlock detector cannot see, so with no <code>lock_timeout</code>
|
|
1094
|
+
the run hangs indefinitely and pins both connections. Reads through the
|
|
1095
|
+
record (<code>reload</code>, <code>associationQuery</code>, ...) likewise run on a separate
|
|
1096
|
+
connection and snapshot. Derive the attributes and return them; Dream
|
|
1097
|
+
performs the write inside the batch's transaction.</li>
|
|
1098
|
+
<li><strong><code>lock: false</code> can throw mid-run when racing a deleter.</strong> On the
|
|
1099
|
+
unlocked paths, a matched record that a concurrent transaction destroys
|
|
1100
|
+
between a batch's read and that record's write aborts the run with an
|
|
1101
|
+
error: earlier batches stay committed, and no count is returned. Use
|
|
1102
|
+
<code>lock: true</code> when deleters may race the update — claimed rows are held
|
|
1103
|
+
under their locks until written.</li>
|
|
1104
|
+
<li><strong>A <code>limit</code> or <code>offset</code> on the Query is incompatible with <code>update</code> on
|
|
1105
|
+
every path.</strong> The batched paths re-apply the Query's conditions to each
|
|
1106
|
+
batch window, where a limit or offset would skip or truncate rows
|
|
1107
|
+
inside every window instead of bounding the run as a whole, and the
|
|
1108
|
+
single-statement <code>skipHooks</code> attributes form cannot express either in
|
|
1109
|
+
its SQL UPDATE. Every form throws rather than silently corrupting the
|
|
1110
|
+
windows or ignoring the caller's scope.</li>
|
|
1111
|
+
<li><strong>A batch waits, without bound, for whoever holds the row.</strong> The locked
|
|
1112
|
+
read is a plain <code>FOR UPDATE</code>: if another transaction already holds a
|
|
1113
|
+
lock on one of the batch's rows, this call blocks until that transaction
|
|
1114
|
+
ends, holding its own transaction and its pooled connection open the
|
|
1115
|
+
whole time. Dream sets no <code>lock_timeout</code> or <code>statement_timeout</code>, so a
|
|
1116
|
+
long-running writer on the other side stalls the run indefinitely and,
|
|
1117
|
+
at scale, ties up connections. If that is a risk in your application,
|
|
1118
|
+
set a <code>lock_timeout</code> on the connection so a stuck batch fails instead of
|
|
1119
|
+
hanging.</li>
|
|
1120
|
+
<li><strong><code>skipHooks</code> composes with <code>lock</code>, but stays on the per-instance
|
|
1121
|
+
path.</strong> With an attributes object and no <code>lock</code>, <code>skipHooks: true</code>
|
|
1122
|
+
issues a single <code>UPDATE ... WHERE</code> statement that writes raw columns.
|
|
1123
|
+
With <code>lock: true</code>, <code>skipHooks: true</code> skips the model hooks on each
|
|
1124
|
+
claimed record but still writes through the instance, so custom setters
|
|
1125
|
+
— including the setters encrypted attributes encrypt through — run as
|
|
1126
|
+
they would for a plain instance update. (Virtual attributes whose
|
|
1127
|
+
processing lives in a hook are still skipped, exactly as in an instance
|
|
1128
|
+
update with <code>skipHooks</code>.) A callback never takes the single-statement
|
|
1129
|
+
path: <code>skipHooks</code> beside a callback only skips the hooks on each
|
|
1130
|
+
per-record write, under <code>lock: true</code> and <code>lock: false</code> alike.</li>
|
|
1131
|
+
<li><strong>If you are updating a large set and do not need compare-and-set, do
|
|
1132
|
+
not pass <code>lock</code>.</strong> Plain <code>update(attributes)</code> (hooks, no locking) or
|
|
1133
|
+
<code>update(attributes, { skipHooks: true })</code> (a single statement, no hooks)
|
|
1134
|
+
are the right tools for bulk updates.</li>
|
|
1135
|
+
</ul>
|
|
1136
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">attributes</span>: <span class="tsd-signature-type">DreamTableSchema</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></span></li><li><span><code class="tsd-tag">Optional</code><span class="tsd-kind-parameter">options</span>: <span class="tsd-signature-symbol">{</span> <span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">false</span><span class="tsd-signature-symbol">;</span> <span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?:</span> <span class="tsd-signature-type">boolean</span> <span class="tsd-signature-symbol">}</span></span><div class="tsd-comment tsd-typography"><p>Options for updating the instance</p>
|
|
1137
|
+
</div><ul class="tsd-parameters"><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">lock</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">false</span></h5><div class="tsd-comment tsd-typography"><p>If true, each batch is re-selected with an exclusive row lock inside its own transaction before being updated, making the update a compare-and-set. Defaults to false for the attributes form; with a callback there is no default — an explicit boolean is required. One typing asymmetry to know: with an attributes object, an explicit <code>lock: false</code> keeps the raw single-statement (<code>DreamTableSchema</code>) typing that <code>skipHooks</code> uses, so virtual/encrypted attributes type-check only when the options object is omitted entirely or <code>lock</code> is <code>true</code></p>
|
|
1138
|
+
</div></li><li class="tsd-parameter"><h5><code class="tsd-tag">Optional</code><span class="tsd-kind-property">skipHooks</span><span class="tsd-signature-symbol">?: </span><span class="tsd-signature-type">boolean</span></h5><div class="tsd-comment tsd-typography"><p>If true, skips applying model hooks. Defaults to false</p>
|
|
1139
|
+
</div></li></ul></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span></h4><p>The number of records that were updated</p>
|
|
1140
|
+
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-15">Throws<a href="#throws-15" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>InvalidBatchSize if <code>batchSize</code> is not a positive integer</p>
|
|
1141
|
+
</div><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-16">Throws<a href="#throws-16" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>MissingRequiredLockOptionForUpdateCallback if a callback is passed without an options object carrying a boolean <code>lock</code></p>
|
|
1142
|
+
</div><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-17">Throws<a href="#throws-17" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>BatchingIncompatibleWithLimitOrOffset if the query carries a <code>limit</code> or <code>offset</code></p>
|
|
1143
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L3164">src/dream/Query.ts:3164</a></li></ul></aside></div></li><li class=""><div class="tsd-signature tsd-anchor-link" id="update-4"><span class="tsd-kind-call-signature">update</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">attributes</span><span class="tsd-signature-symbol">:</span> <a href="../types/types.UpdateableProperties.html" class="tsd-signature-type tsd-kind-type-alias">UpdateableProperties</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span><a href="#update-4" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Updates all records matching the Query</p>
|
|
1144
|
+
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-4">ops</span><span class="hl-1">.</span><span class="hl-5">ilike</span><span class="hl-1">(</span><span class="hl-6">'%burpcollaborator%'</span><span class="hl-1">) }).</span><span class="hl-5">update</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-0">null</span><span class="hl-1"> })</span><br/><span class="hl-7">// 12</span>
|
|
1145
|
+
</code><button type="button">Copy</button></pre>
|
|
1146
|
+
|
|
1147
|
+
<p>Instead of an attributes object, the first argument may be a callback
|
|
1148
|
+
that derives each record's attributes from the record itself. The
|
|
1149
|
+
callback (sync or async) receives each matching record and returns the
|
|
1150
|
+
attributes to write for it, or <code>undefined</code> to skip it — a skipped record
|
|
1151
|
+
gets no write, runs no hooks, and is not counted (a <code>null</code> return, from
|
|
1152
|
+
untyped callers, is treated the same). Only the returned attributes are
|
|
1153
|
+
written: the callback receives a clone of the record, so mutations made
|
|
1154
|
+
directly on the received record are discarded rather than riding along
|
|
1155
|
+
with the write. With a callback, the options object and its <code>lock</code> key
|
|
1156
|
+
are mandatory, and <code>lock</code> is a full boolean, so every call site says out
|
|
1157
|
+
loud whether the callback runs under row locks:</p>
|
|
1158
|
+
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">update</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-4">user</span><span class="hl-1"> </span><span class="hl-0">=></span><span class="hl-1"> (</span><span class="hl-4">user</span><span class="hl-1">.</span><span class="hl-4">email</span><span class="hl-1">.</span><span class="hl-5">endsWith</span><span class="hl-1">(</span><span class="hl-6">'@example.com'</span><span class="hl-1">) ? { </span><span class="hl-4">name:</span><span class="hl-1"> </span><span class="hl-6">'example user'</span><span class="hl-1"> } : </span><span class="hl-0">undefined</span><span class="hl-1">),</span><br/><span class="hl-1"> { </span><span class="hl-4">lock:</span><span class="hl-1"> </span><span class="hl-0">false</span><span class="hl-1"> }</span><br/><span class="hl-1">)</span>
|
|
1159
|
+
</code><button type="button">Copy</button></pre>
|
|
1160
|
+
|
|
1161
|
+
<p>Under <code>lock: false</code>, the callback runs once per matching record —
|
|
1162
|
+
batched reads (<code>batchSize</code> defaults to 1000 here), no locks, no claim
|
|
1163
|
+
step, no compare-and-set guarantee — the right shape for a derived
|
|
1164
|
+
backfill where racing writers are not a concern. (On a <code>@ReplicaSafe</code>
|
|
1165
|
+
model, these unlocked batch reads may come from a lagging replica,
|
|
1166
|
+
feeding stale column values into the callback; use <code>lock: true</code> to
|
|
1167
|
+
derive from the freshest committed state — its transactional reads pin
|
|
1168
|
+
the primary.) Under <code>lock: true</code>, the callback runs once per claimed
|
|
1169
|
+
record, under that record's row lock, inside the batch's transaction,
|
|
1170
|
+
receiving a clone of the freshly locked read; Dream applies the returned
|
|
1171
|
+
attributes to the record it holds and writes before the batch commits,
|
|
1172
|
+
so there is no transaction handle for the caller to forget. (The record
|
|
1173
|
+
the callback receives is not bound to the batch's transaction — see the
|
|
1174
|
+
callback bullet below before touching the database from inside a
|
|
1175
|
+
callback.) That makes the callback form the tool
|
|
1176
|
+
for serializing writers on state a <code>WHERE</code> clause cannot express — for
|
|
1177
|
+
example an <code>@Encrypted</code> column, whose ciphertext changes on every write
|
|
1178
|
+
and whose plaintext has no column to compare against in the database:</p>
|
|
1179
|
+
<pre><code class="ts"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">rotated</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">id:</span><span class="hl-1"> </span><span class="hl-4">userId</span><span class="hl-1"> }).</span><span class="hl-5">update</span><span class="hl-1">(</span><br/><span class="hl-1"> </span><span class="hl-4">user</span><span class="hl-1"> </span><span class="hl-0">=></span><span class="hl-1"> (</span><span class="hl-4">user</span><span class="hl-1">.</span><span class="hl-4">secret</span><span class="hl-1"> === </span><span class="hl-4">expectedSecret</span><span class="hl-1"> ? { </span><span class="hl-4">secret:</span><span class="hl-1"> </span><span class="hl-4">newSecret</span><span class="hl-1"> } : </span><span class="hl-0">undefined</span><span class="hl-1">),</span><br/><span class="hl-1"> { </span><span class="hl-4">lock:</span><span class="hl-1"> </span><span class="hl-0">true</span><span class="hl-1"> }</span><br/><span class="hl-1">)</span><br/><span class="hl-7">// 1 — or 0, if a competing writer got there first (the callback saw a</span><br/><span class="hl-7">// different secret and skipped the record)</span>
|
|
1180
|
+
</code><button type="button">Copy</button></pre>
|
|
1181
|
+
|
|
1182
|
+
<p>With a callback, the returned count is the number of records the
|
|
1183
|
+
callback returned attributes for: skipped records are not counted, and
|
|
1184
|
+
under <code>lock: true</code> records that lost the race never reach the callback
|
|
1185
|
+
at all. (As with the attributes form, a write that turns out to be a
|
|
1186
|
+
no-op still counts — the count means "the callback chose to write", not
|
|
1187
|
+
"SQL was emitted".)</p>
|
|
1188
|
+
<p>The <code>lock</code> option turns the update into a guarded (compare-and-set)
|
|
1189
|
+
update: each record is written only if it still matches the Query at the
|
|
1190
|
+
moment an exclusive row lock on it is acquired. Use it when the Query's
|
|
1191
|
+
conditions are the thing being changed and a concurrent writer racing this
|
|
1192
|
+
call must not have its write clobbered:</p>
|
|
1193
|
+
<pre><code class="ts"><span class="hl-0">const</span><span class="hl-1"> </span><span class="hl-2">updated</span><span class="hl-1"> = </span><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">Order</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">status:</span><span class="hl-1"> </span><span class="hl-6">'pending'</span><span class="hl-1"> })</span><br/><span class="hl-1"> .</span><span class="hl-5">update</span><span class="hl-1">({ </span><span class="hl-4">status:</span><span class="hl-1"> </span><span class="hl-6">'processing'</span><span class="hl-1"> }, { </span><span class="hl-4">lock:</span><span class="hl-1"> </span><span class="hl-0">true</span><span class="hl-1"> })</span><br/><span class="hl-7">// 0 — someone else moved every one of them out of 'pending' first</span>
|
|
1194
|
+
</code><button type="button">Copy</button></pre>
|
|
1195
|
+
|
|
1196
|
+
<p>With <code>lock: true</code>, records are processed in batches, and each batch runs
|
|
1197
|
+
in its own transaction which first re-selects that batch's records with an
|
|
1198
|
+
exclusive row lock and then updates them before committing. Because the
|
|
1199
|
+
database re-checks the Query's conditions after acquiring each row lock, a
|
|
1200
|
+
record a concurrent transaction has already moved out of the Query drops
|
|
1201
|
+
out of the locked read and is never updated. The returned count is the
|
|
1202
|
+
number of records claimed and submitted for writing, so a caller can
|
|
1203
|
+
detect that it lost a race by comparing the count against what it
|
|
1204
|
+
expected. (A claimed record whose write turns out to be a no-op — the
|
|
1205
|
+
attributes already match, or a hook cleared every dirty attribute — still
|
|
1206
|
+
counts; the count is not a guarantee that SQL was emitted per counted
|
|
1207
|
+
record.)</p>
|
|
1208
|
+
<p>Things to know before relying on it:</p>
|
|
1209
|
+
<ul>
|
|
1210
|
+
<li><strong>The guarantee is per batch, not set-wide.</strong> A run spanning more than
|
|
1211
|
+
one batch can win a race in batch 1 and lose one in batch 2; nothing
|
|
1212
|
+
holds the whole matched set still for the duration of the run. Sharing
|
|
1213
|
+
one transaction across every batch — by threading a transaction onto the
|
|
1214
|
+
Query itself, <code>Order.query().txn(txn).where({ ... }).update({ ... }, { lock: true })</code> — buys two things: the updates become all-or-nothing (a
|
|
1215
|
+
rollback undoes the whole run), and the row locks taken by every batch
|
|
1216
|
+
are held until you commit. It does <strong>not</strong> extend the compare-and-set to
|
|
1217
|
+
the part of the set the run has not reached yet: under READ COMMITTED
|
|
1218
|
+
each statement takes a fresh snapshot, so a record moved out of the
|
|
1219
|
+
Query between batch 1 and batch 2 still drops out of batch 2's locked
|
|
1220
|
+
read. A genuinely set-wide guarantee needs REPEATABLE READ /
|
|
1221
|
+
SERIALIZABLE, or a single locking statement over the whole set.</li>
|
|
1222
|
+
<li><strong>Only a transaction carried by the Query is shared.</strong> Merely wrapping
|
|
1223
|
+
the call in <code>Model.transaction(...)</code> does not thread that transaction
|
|
1224
|
+
onto the Query — <code>Dream.transaction</code> establishes no ambient transaction,
|
|
1225
|
+
it only hands a <code>txn</code> to your callback — so each batch would open its
|
|
1226
|
+
own transaction on a different pooled connection. Worse, if the
|
|
1227
|
+
surrounding transaction has already written to any of the matched rows,
|
|
1228
|
+
each batch's locked read blocks on locks the surrounding transaction
|
|
1229
|
+
holds while that transaction awaits the update: a cycle across two
|
|
1230
|
+
connections, which Postgres's deadlock detector cannot see, so it hangs
|
|
1231
|
+
rather than aborting. Always pass the transaction with <code>.txn(txn)</code>.</li>
|
|
1232
|
+
<li><strong>Behavior above READ COMMITTED differs.</strong> The drop-out-of-the-result
|
|
1233
|
+
behavior described above is READ COMMITTED (Postgres's default). Under
|
|
1234
|
+
REPEATABLE READ or SERIALIZABLE, the same race raises a serialization
|
|
1235
|
+
failure instead of silently returning a lower count. Both are safe; only
|
|
1236
|
+
one of them is quiet.</li>
|
|
1237
|
+
<li><strong><code>batchSize</code> defaults to 10 here</strong>, not <code>findEach</code>'s 1000, and the
|
|
1238
|
+
default is deliberately small. Every row in a batch stays locked for the
|
|
1239
|
+
whole batch, including the time spent running each record's hooks — and,
|
|
1240
|
+
on the callback form, the time spent running the Query's <code>preload</code>
|
|
1241
|
+
queries, which are fetched inside the lock window (the attributes form
|
|
1242
|
+
strips preloads, which it never consumes) — so an oversized batch blocks
|
|
1243
|
+
unrelated writers touching those rows and surfaces as timeouts somewhere
|
|
1244
|
+
else in the application, which is very hard to trace back to this
|
|
1245
|
+
update. Too small a batch, by contrast, only slows down this call, which
|
|
1246
|
+
you can see and fix. Lower it further for models with expensive update
|
|
1247
|
+
hooks.</li>
|
|
1248
|
+
<li><strong>The callback must not write to the database.</strong> The record handed to
|
|
1249
|
+
the callback is not bound to the batch's transaction: a write through it
|
|
1250
|
+
(e.g. <code>await record.update(...)</code>) goes out on a different pooled
|
|
1251
|
+
connection and blocks on the batch's own row locks while the batch
|
|
1252
|
+
transaction waits on the callback — a cycle across two connections that
|
|
1253
|
+
the database's deadlock detector cannot see, so with no <code>lock_timeout</code>
|
|
1254
|
+
the run hangs indefinitely and pins both connections. Reads through the
|
|
1255
|
+
record (<code>reload</code>, <code>associationQuery</code>, ...) likewise run on a separate
|
|
1256
|
+
connection and snapshot. Derive the attributes and return them; Dream
|
|
1257
|
+
performs the write inside the batch's transaction.</li>
|
|
1258
|
+
<li><strong><code>lock: false</code> can throw mid-run when racing a deleter.</strong> On the
|
|
1259
|
+
unlocked paths, a matched record that a concurrent transaction destroys
|
|
1260
|
+
between a batch's read and that record's write aborts the run with an
|
|
1261
|
+
error: earlier batches stay committed, and no count is returned. Use
|
|
1262
|
+
<code>lock: true</code> when deleters may race the update — claimed rows are held
|
|
1263
|
+
under their locks until written.</li>
|
|
1264
|
+
<li><strong>A <code>limit</code> or <code>offset</code> on the Query is incompatible with <code>update</code> on
|
|
1265
|
+
every path.</strong> The batched paths re-apply the Query's conditions to each
|
|
1266
|
+
batch window, where a limit or offset would skip or truncate rows
|
|
1267
|
+
inside every window instead of bounding the run as a whole, and the
|
|
1268
|
+
single-statement <code>skipHooks</code> attributes form cannot express either in
|
|
1269
|
+
its SQL UPDATE. Every form throws rather than silently corrupting the
|
|
1270
|
+
windows or ignoring the caller's scope.</li>
|
|
1271
|
+
<li><strong>A batch waits, without bound, for whoever holds the row.</strong> The locked
|
|
1272
|
+
read is a plain <code>FOR UPDATE</code>: if another transaction already holds a
|
|
1273
|
+
lock on one of the batch's rows, this call blocks until that transaction
|
|
1274
|
+
ends, holding its own transaction and its pooled connection open the
|
|
1275
|
+
whole time. Dream sets no <code>lock_timeout</code> or <code>statement_timeout</code>, so a
|
|
1276
|
+
long-running writer on the other side stalls the run indefinitely and,
|
|
1277
|
+
at scale, ties up connections. If that is a risk in your application,
|
|
1278
|
+
set a <code>lock_timeout</code> on the connection so a stuck batch fails instead of
|
|
1279
|
+
hanging.</li>
|
|
1280
|
+
<li><strong><code>skipHooks</code> composes with <code>lock</code>, but stays on the per-instance
|
|
1281
|
+
path.</strong> With an attributes object and no <code>lock</code>, <code>skipHooks: true</code>
|
|
1282
|
+
issues a single <code>UPDATE ... WHERE</code> statement that writes raw columns.
|
|
1283
|
+
With <code>lock: true</code>, <code>skipHooks: true</code> skips the model hooks on each
|
|
1284
|
+
claimed record but still writes through the instance, so custom setters
|
|
1285
|
+
— including the setters encrypted attributes encrypt through — run as
|
|
1286
|
+
they would for a plain instance update. (Virtual attributes whose
|
|
1287
|
+
processing lives in a hook are still skipped, exactly as in an instance
|
|
1288
|
+
update with <code>skipHooks</code>.) A callback never takes the single-statement
|
|
1289
|
+
path: <code>skipHooks</code> beside a callback only skips the hooks on each
|
|
1290
|
+
per-record write, under <code>lock: true</code> and <code>lock: false</code> alike.</li>
|
|
1291
|
+
<li><strong>If you are updating a large set and do not need compare-and-set, do
|
|
1292
|
+
not pass <code>lock</code>.</strong> Plain <code>update(attributes)</code> (hooks, no locking) or
|
|
1293
|
+
<code>update(attributes, { skipHooks: true })</code> (a single statement, no hooks)
|
|
1294
|
+
are the right tools for bulk updates.</li>
|
|
1295
|
+
</ul>
|
|
1296
|
+
</div><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">attributes</span>: <a href="../types/types.UpdateableProperties.html" class="tsd-signature-type tsd-kind-type-alias">UpdateableProperties</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">></span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">Promise</span><span class="tsd-signature-symbol"><</span><span class="tsd-signature-type">number</span><span class="tsd-signature-symbol">></span></h4><p>The number of records that were updated</p>
|
|
1297
|
+
<div class="tsd-comment tsd-typography"><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-18">Throws<a href="#throws-18" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>InvalidBatchSize if <code>batchSize</code> is not a positive integer</p>
|
|
1298
|
+
</div><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-19">Throws<a href="#throws-19" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>MissingRequiredLockOptionForUpdateCallback if a callback is passed without an options object carrying a boolean <code>lock</code></p>
|
|
1299
|
+
</div><div class="tsd-tag-throws"><h4 class="tsd-anchor-link" id="throws-20">Throws<a href="#throws-20" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h4><p>BatchingIncompatibleWithLimitOrOffset if the query carries a <code>limit</code> or <code>offset</code></p>
|
|
1300
|
+
</div></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L3168">src/dream/Query.ts:3168</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="where"><span>where</span><a href="#where" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="where-1"><span class="tsd-kind-call-signature">where</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#wheredb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#whereschema">Schema</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">whereStatement</span><span class="tsd-signature-symbol">:</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">WhereStatementForJoinedAssociation</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#wheredb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#whereschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#where-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Applies a where statement to the Query instance</p>
|
|
639
1301
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">where</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-6">'how@yadoin'</span><span class="hl-1"> }).</span><span class="hl-5">first</span><span class="hl-1">()</span><br/><span class="hl-7">// User{email: 'how@yadoin'}</span>
|
|
640
1302
|
</code><button type="button">Copy</button></pre>
|
|
641
1303
|
|
|
642
1304
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="wheredb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="whereschema"><span class="tsd-kind-type-parameter">Schema</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">whereStatement</span>: <br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">WhereStatementForJoinedAssociation</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#wheredb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#whereschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span></span><div class="tsd-comment tsd-typography"><p>Where statement to apply to the Query</p>
|
|
643
1305
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><p>A cloned Query with the where clause applied</p>
|
|
644
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
1306
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1268">src/dream/Query.ts:1268</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="whereany"><span>where<wbr/>Any</span><a href="#whereany" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="whereany-1"><span class="tsd-kind-call-signature">whereAny</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#whereanydb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#whereanyschema">Schema</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">whereStatements</span><span class="tsd-signature-symbol">:</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">WhereStatementForJoinedAssociation</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#whereanydb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#whereanyschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#whereany-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Accepts a list of where statements, each of
|
|
645
1307
|
which is combined via <code>OR</code></p>
|
|
646
1308
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">whereAny</span><span class="hl-1">([{ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-6">'how@yadoin'</span><span class="hl-1"> }, { </span><span class="hl-4">name:</span><span class="hl-1"> </span><span class="hl-6">'fred'</span><span class="hl-1"> }]).</span><span class="hl-5">first</span><span class="hl-1">()</span><br/><span class="hl-7">// [User{email: 'how@yadoin'}, User{name: 'fred'}, User{name: 'fred'}]</span>
|
|
647
1309
|
</code><button type="button">Copy</button></pre>
|
|
648
1310
|
|
|
649
1311
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="whereanydb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="whereanyschema"><span class="tsd-kind-type-parameter">Schema</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">whereStatements</span>: <br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">WhereStatementForJoinedAssociation</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#whereanydb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#whereanyschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">[]</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span></span><div class="tsd-comment tsd-typography"><p>a list of where statements to <code>OR</code> together</p>
|
|
650
1312
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><p>A cloned Query with the whereAny clause applied</p>
|
|
651
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/
|
|
1313
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1292">src/dream/Query.ts:1292</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="wherenot"><span>where<wbr/>Not</span><a href="#wherenot" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="wherenot-1"><span class="tsd-kind-call-signature">whereNot</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#wherenotdb">DB</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#wherenotschema">Schema</a> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><br/> <span class="tsd-kind-parameter">whereStatement</span><span class="tsd-signature-symbol">:</span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">WhereStatementForJoinedAssociation</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#wherenotdb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#wherenotschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span><span class="tsd-signature-symbol">,</span><br/><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span><a href="#wherenot-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><div class="tsd-comment tsd-typography"><p>Applies a whereNot statement to the Query instance</p>
|
|
652
1314
|
<pre><code class="ts"><span class="hl-3">await</span><span class="hl-1"> </span><span class="hl-4">User</span><span class="hl-1">.</span><span class="hl-5">query</span><span class="hl-1">().</span><span class="hl-5">whereNot</span><span class="hl-1">({ </span><span class="hl-4">email:</span><span class="hl-1"> </span><span class="hl-6">'how@yadoin'</span><span class="hl-1"> }).</span><span class="hl-5">first</span><span class="hl-1">()</span><br/><span class="hl-7">// User{email: 'hello@world'}</span>
|
|
653
1315
|
</code><button type="button">Copy</button></pre>
|
|
654
1316
|
|
|
655
1317
|
</div><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="wherenotdb"><span class="tsd-kind-type-parameter">DB</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li><li><span id="wherenotschema"><span class="tsd-kind-type-parameter">Schema</span> <span class="tsd-signature-keyword">extends</span> <span class="tsd-signature-type">any</span></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">whereStatement</span>: <br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">WhereStatementForJoinedAssociation</span><span class="tsd-signature-symbol"><</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"joinedAssociations"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#wherenotdb">DB</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#wherenotschema">Schema</a><span class="tsd-signature-symbol">,</span><br/> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">[</span><span class="tsd-signature-type">"rootTableName"</span><span class="tsd-signature-symbol">]</span><span class="tsd-signature-symbol">,</span><br/> <span class="tsd-signature-symbol">></span><br/> <span class="tsd-signature-symbol">|</span> <span class="tsd-signature-type">null</span></span><div class="tsd-comment tsd-typography"><p>A where statement to negate and apply to the Query</p>
|
|
656
1318
|
</div></li></ul></div><h4 class="tsd-returns-title">Returns <a href="" class="tsd-signature-type tsd-kind-class">Query</a><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dreaminstance">DreamInstance</a><span class="tsd-signature-symbol">,</span> <a class="tsd-signature-type tsd-kind-type-parameter" href="#querytypeopts">QueryTypeOpts</a><span class="tsd-signature-symbol">></span></h4><p>A cloned Query with the whereNot clause applied</p>
|
|
657
|
-
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/276ab87aae35de8dce4d5a4e3052373f512d2717/src/dream/Query.ts#L1302">src/dream/Query.ts:1302</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="dbdriverclass"><code class="tsd-tag">Static</code><span>db<wbr/>Driver<wbr/>Class</span><a href="#dbdriverclass" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="dbdriverclass-1"><span class="tsd-kind-call-signature">dbDriverClass</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dbdriverclasst">T</a> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">connectionName</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-keyword">typeof</span> <a href="db.QueryDriverBase.html" class="tsd-signature-type tsd-kind-class">QueryDriverBase</a><a href="#dbdriverclass-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="dbdriverclasst"><span class="tsd-kind-type-parameter">T</span> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">connectionName</span>: <span class="tsd-signature-type">string</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-keyword">typeof</span> <a href="db.QueryDriverBase.html" class="tsd-signature-type tsd-kind-class">QueryDriverBase</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/276ab87aae35de8dce4d5a4e3052373f512d2717/src/dream/Query.ts#L2076">src/dream/Query.ts:2076</a></li></ul></aside></div></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#connectionoverride" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>connection<wbr/>Override</span></a><a href="#dreamclass" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>dream<wbr/>Class</span></a><a href="#dreaminstance-1"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>dream<wbr/>Instance</span></a><a href="#dreamtransaction"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>dream<wbr/>Transaction</span></a><a href="#innerjoindreamclasses" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>inner<wbr/>Join<wbr/>Dream<wbr/>Classes</span></a><a href="#querytypeopts-1"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>query<wbr/>Type<wbr/>Opts</span></a><a href="#batch_sizes"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>BATCH_<wbr/>SIZES</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Accessors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Accessors</summary><div><a href="#connectionname"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Accessor"><use href="../assets/icons.svg#icon-262144"></use></svg><span>connection<wbr/>Name</span></a><a href="#isdreamquery"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Accessor"><use href="../assets/icons.svg#icon-262144"></use></svg><span>is<wbr/>Dream<wbr/>Query</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#all"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>all</span></a><a href="#avg"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>avg</span></a><a href="#avgby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>avg<wbr/>By</span></a><a href="#clone"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>clone</span></a><a href="#connection"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>connection</span></a><a href="#count"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>count</span></a><a href="#countby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>count<wbr/>By</span></a><a href="#cursorpaginate"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>cursor<wbr/>Paginate</span></a><a href="#dbdriverinstance"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>db<wbr/>Driver<wbr/>Instance</span></a><a href="#delete"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>delete</span></a><a href="#destroy"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>destroy</span></a><ul><li><ul><li><a href="#guarded-compare-and-set-destroy"><span>Guarded (compare-<wbr/>and-<wbr/>set) destroy</span></a></li></ul></li></ul><a href="#distinct"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>distinct</span></a><a href="#exists"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>exists</span></a><a href="#find"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>find</span></a><a href="#findby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>find<wbr/>By</span></a><a href="#findeach"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>find<wbr/>Each</span></a><a href="#findorfail"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>find<wbr/>Or<wbr/>Fail</span></a><a href="#findorfailby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>find<wbr/>Or<wbr/>Fail<wbr/>By</span></a><a href="#first"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>first</span></a><a href="#firstorfail"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>first<wbr/>Or<wbr/>Fail</span></a><a href="#innerjoin"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>inner<wbr/>Join</span></a><a href="#last"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>last</span></a><a href="#lastorfail"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>last<wbr/>Or<wbr/>Fail</span></a><a href="#leftjoin"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>left<wbr/>Join</span></a><a href="#leftjoinpreload"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>left<wbr/>Join<wbr/>Preload</span></a><a href="#limit"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>limit</span></a><a href="#max"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>max</span></a><a href="#maxby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>max<wbr/>By</span></a><a href="#min"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>min</span></a><a href="#minby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>min<wbr/>By</span></a><a href="#nestedselect"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>nested<wbr/>Select</span></a><a href="#offset"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>offset</span></a><a href="#order"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>order</span></a><a href="#paginate"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>paginate</span></a><a href="#passthrough"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>passthrough</span></a><a href="#pluck"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>pluck</span></a><a href="#pluckeach"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>pluck<wbr/>Each</span></a><a href="#preload"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>preload</span></a><a href="#preloadfor"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>preload<wbr/>For</span></a><a href="#reallydestroy"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>really<wbr/>Destroy</span></a><a href="#removealldefaultscopes"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>remove<wbr/>All<wbr/>Default<wbr/>Scopes</span></a><a href="#removealldefaultscopesexceptonassociations" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>remove<wbr/>All<wbr/>Default<wbr/>Scopes<wbr/>Except<wbr/>On<wbr/>Associations</span></a><a href="#removedefaultscope"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>remove<wbr/>Default<wbr/>Scope</span></a><a href="#removedefaultscopeexceptonassociations" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>remove<wbr/>Default<wbr/>Scope<wbr/>Except<wbr/>On<wbr/>Associations</span></a><a href="#scrollpaginate"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>scroll<wbr/>Paginate</span></a><a href="#sql"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>sql</span></a><a href="#sum"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>sum</span></a><a href="#sumby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>sum<wbr/>By</span></a><a href="#tokysely"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Kysely</span></a><a href="#txn"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>txn</span></a><a href="#undestroy"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>undestroy</span></a><a href="#update"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>update</span></a><a href="#where"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>where</span></a><a href="#whereany"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>where<wbr/>Any</span></a><a href="#wherenot"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>where<wbr/>Not</span></a><a href="#dbdriverclass"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>db<wbr/>Driver<wbr/>Class</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@rvoh/dream</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|
|
1319
|
+
<aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L1319">src/dream/Query.ts:1319</a></li></ul></aside></div></li></ul></section><section class="tsd-panel tsd-member"><h3 class="tsd-anchor-link" id="dbdriverclass"><code class="tsd-tag">Static</code><span>db<wbr/>Driver<wbr/>Class</span><a href="#dbdriverclass" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></h3><ul class="tsd-signatures"><li class=""><div class="tsd-signature tsd-anchor-link" id="dbdriverclass-1"><span class="tsd-kind-call-signature">dbDriverClass</span><span class="tsd-signature-symbol"><</span><a class="tsd-signature-type tsd-kind-type-parameter" href="#dbdriverclasst">T</a> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a><span class="tsd-signature-symbol">></span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">connectionName</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">string</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-keyword">typeof</span> <a href="db.QueryDriverBase.html" class="tsd-signature-type tsd-kind-class">QueryDriverBase</a><a href="#dbdriverclass-1" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24" aria-hidden="true"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></div><div class="tsd-description"><section class="tsd-panel"><h4>Type Parameters</h4><ul class="tsd-type-parameter-list"><li><span id="dbdriverclasst"><span class="tsd-kind-type-parameter">T</span> <span class="tsd-signature-keyword">extends</span> <a href="index.Dream.html" class="tsd-signature-type tsd-kind-class">Dream</a></span></li></ul></section><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">connectionName</span>: <span class="tsd-signature-type">string</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-keyword">typeof</span> <a href="db.QueryDriverBase.html" class="tsd-signature-type tsd-kind-class">QueryDriverBase</a></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/rvohealth/dream/blob/20d78e029954e59b08f2f6ff36b996308eee06fe/src/dream/Query.ts#L2115">src/dream/Query.ts:2115</a></li></ul></aside></div></li></ul></section></section></details></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div><details open class="tsd-accordion tsd-page-navigation"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>On This Page</h3></summary><div class="tsd-accordion-details"><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Constructors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Constructors</summary><div><a href="#constructor"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Constructor"><use href="../assets/icons.svg#icon-512"></use></svg><span>constructor</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Properties"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Properties</summary><div><a href="#connectionoverride" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>connection<wbr/>Override</span></a><a href="#dreamclass" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>dream<wbr/>Class</span></a><a href="#dreaminstance-1"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>dream<wbr/>Instance</span></a><a href="#dreamtransaction"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>dream<wbr/>Transaction</span></a><a href="#innerjoindreamclasses" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>inner<wbr/>Join<wbr/>Dream<wbr/>Classes</span></a><a href="#querytypeopts-1"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>query<wbr/>Type<wbr/>Opts</span></a><a href="#batch_sizes"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Property"><use href="../assets/icons.svg#icon-1024"></use></svg><span>BATCH_<wbr/>SIZES</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Accessors"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Accessors</summary><div><a href="#connectionname"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Accessor"><use href="../assets/icons.svg#icon-262144"></use></svg><span>connection<wbr/>Name</span></a><a href="#isdreamquery"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Accessor"><use href="../assets/icons.svg#icon-262144"></use></svg><span>is<wbr/>Dream<wbr/>Query</span></a></div></details><details open class="tsd-accordion tsd-page-navigation-section"><summary class="tsd-accordion-summary" data-key="section-Methods"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Methods</summary><div><a href="#all"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>all</span></a><a href="#avg"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>avg</span></a><a href="#avgby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>avg<wbr/>By</span></a><a href="#clone"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>clone</span></a><a href="#connection"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>connection</span></a><a href="#count"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>count</span></a><a href="#countby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>count<wbr/>By</span></a><a href="#cursorpaginate"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>cursor<wbr/>Paginate</span></a><a href="#dbdriverinstance"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>db<wbr/>Driver<wbr/>Instance</span></a><a href="#delete"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>delete</span></a><a href="#destroy"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>destroy</span></a><ul><li><ul><li><a href="#guarded-compare-and-set-destroy"><span>Guarded (compare-<wbr/>and-<wbr/>set) destroy</span></a></li></ul></li></ul><a href="#distinct"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>distinct</span></a><a href="#exists"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>exists</span></a><a href="#find"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>find</span></a><a href="#findby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>find<wbr/>By</span></a><a href="#findeach"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>find<wbr/>Each</span></a><a href="#findorfail"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>find<wbr/>Or<wbr/>Fail</span></a><a href="#findorfailby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>find<wbr/>Or<wbr/>Fail<wbr/>By</span></a><a href="#first"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>first</span></a><a href="#firstorfail"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>first<wbr/>Or<wbr/>Fail</span></a><a href="#innerjoin"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>inner<wbr/>Join</span></a><a href="#last"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>last</span></a><a href="#lastorfail"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>last<wbr/>Or<wbr/>Fail</span></a><a href="#leftjoin"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>left<wbr/>Join</span></a><a href="#leftjoinpreload"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>left<wbr/>Join<wbr/>Preload</span></a><a href="#limit"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>limit</span></a><a href="#max"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>max</span></a><a href="#maxby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>max<wbr/>By</span></a><a href="#min"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>min</span></a><a href="#minby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>min<wbr/>By</span></a><a href="#nestedselect"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>nested<wbr/>Select</span></a><a href="#offset"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>offset</span></a><a href="#order"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>order</span></a><a href="#paginate"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>paginate</span></a><a href="#passthrough"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>passthrough</span></a><a href="#pluck"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>pluck</span></a><a href="#pluckeach"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>pluck<wbr/>Each</span></a><a href="#preload"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>preload</span></a><a href="#preloadfor"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>preload<wbr/>For</span></a><a href="#reallydestroy"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>really<wbr/>Destroy</span></a><a href="#removealldefaultscopes"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>remove<wbr/>All<wbr/>Default<wbr/>Scopes</span></a><a href="#removealldefaultscopesexceptonassociations" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>remove<wbr/>All<wbr/>Default<wbr/>Scopes<wbr/>Except<wbr/>On<wbr/>Associations</span></a><a href="#removedefaultscope"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>remove<wbr/>Default<wbr/>Scope</span></a><a href="#removedefaultscopeexceptonassociations" class="tsd-is-protected"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>remove<wbr/>Default<wbr/>Scope<wbr/>Except<wbr/>On<wbr/>Associations</span></a><a href="#scrollpaginate"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>scroll<wbr/>Paginate</span></a><a href="#sql"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>sql</span></a><a href="#sum"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>sum</span></a><a href="#sumby"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>sum<wbr/>By</span></a><a href="#tokysely"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>to<wbr/>Kysely</span></a><a href="#txn"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>txn</span></a><a href="#undestroy"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>undestroy</span></a><a href="#update"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>update</span></a><a href="#where"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>where</span></a><a href="#whereany"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>where<wbr/>Any</span></a><a href="#wherenot"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>where<wbr/>Not</span></a><a href="#dbdriverclass"><svg class="tsd-kind-icon" viewBox="0 0 24 24" aria-label="Method"><use href="../assets/icons.svg#icon-2048"></use></svg><span>db<wbr/>Driver<wbr/>Class</span></a></div></details></div></details></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">@rvoh/dream</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
|