orange-orm 3.10.2
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/.dockerignore +1 -0
- package/.eslintignore +2 -0
- package/.eslintrc.js +45 -0
- package/.gitattributes +3 -0
- package/CNAME +1 -0
- package/CONTRIBUTING.md +43 -0
- package/LICENSE +7 -0
- package/README.md +1969 -0
- package/SECURITY.md +12 -0
- package/bin/build.js +127 -0
- package/bin/compile.js +26 -0
- package/bin/rdb.js +4 -0
- package/docs/CODE_OF_CONDUCT.md +18 -0
- package/docs/changelog.md +461 -0
- package/docs/docs.md +2373 -0
- package/docs/orange.svg +32 -0
- package/docs/relations.png +0 -0
- package/package.json +139 -0
- package/src/applyPatch.js +105 -0
- package/src/client/axiosInterceptor.js +46 -0
- package/src/client/clientMap.js +72 -0
- package/src/client/createPatch.js +122 -0
- package/src/client/createProviders.js +121 -0
- package/src/client/index.js +997 -0
- package/src/client/index.mjs +6295 -0
- package/src/client/map.js +110 -0
- package/src/client/merge.js +9 -0
- package/src/client/netAdapter.js +133 -0
- package/src/client/rollup.config.js +12 -0
- package/src/client/self.js +4 -0
- package/src/client/stringify.js +22 -0
- package/src/client/toKeyPositionMap.js +30 -0
- package/src/clsTest.js +79 -0
- package/src/createDomain/negotiateForwardProperty.js +23 -0
- package/src/createDomain.js +31 -0
- package/src/dateToISOString.js +25 -0
- package/src/emitEvent.js +46 -0
- package/src/emptyFilter.js +35 -0
- package/src/flags.js +6 -0
- package/src/fromCompareObject.js +24 -0
- package/src/generic-pool.js +641 -0
- package/src/getManyDto/newQuery.js +18 -0
- package/src/getManyDto/query/newColumnSql.js +8 -0
- package/src/getManyDto/query/newSingleQuery.js +19 -0
- package/src/getManyDto/query/singleQuery/newJoinedColumnSql.js +25 -0
- package/src/getManyDto/query/singleQuery/newShallowColumnSql.js +25 -0
- package/src/getManyDto.js +255 -0
- package/src/getTSDefinition.js +510 -0
- package/src/hostExpress/executePath.js +433 -0
- package/src/hostExpress/getMeta.js +49 -0
- package/src/hostExpress.js +125 -0
- package/src/hostLocal.js +110 -0
- package/src/index.d.ts +324 -0
- package/src/index.js +116 -0
- package/src/jsconfig.json +8 -0
- package/src/lock/toIntKey.js +35 -0
- package/src/lock.js +26 -0
- package/src/map.d.ts +1729 -0
- package/src/mssql/encodeBuffer.js +7 -0
- package/src/mssql/newDatabase.js +129 -0
- package/src/mssql/newPool.js +19 -0
- package/src/mssql/newTransaction.js +69 -0
- package/src/mssql/pool/defaults.js +45 -0
- package/src/mssql/pool/end.js +13 -0
- package/src/mssql/pool/newGenericPool.js +62 -0
- package/src/mssql/wrapQuery.js +34 -0
- package/src/mySql/deleteFromSql.js +8 -0
- package/src/mySql/encodeBoolean.js +7 -0
- package/src/mySql/insert.js +21 -0
- package/src/mySql/insertSql.js +62 -0
- package/src/mySql/lastInsertedSql.js +11 -0
- package/src/mySql/limitAndOffset.js +18 -0
- package/src/mySql/newDatabase.js +127 -0
- package/src/mySql/newPool.js +19 -0
- package/src/mySql/newTransaction.js +54 -0
- package/src/mySql/pool/defaults.js +16 -0
- package/src/mySql/pool/end.js +13 -0
- package/src/mySql/pool/negotiatePoolOptions.js +12 -0
- package/src/mySql/pool/newGenericPool.js +67 -0
- package/src/mySql/selectForUpdateSql.js +3 -0
- package/src/mySql/wrapQuery.js +16 -0
- package/src/mySql/wrapQueryStream.js +9 -0
- package/src/newArray.js +3 -0
- package/src/newCollection.js +55 -0
- package/src/newId.js +1 -0
- package/src/newImmutable.js +22 -0
- package/src/newObject.js +5 -0
- package/src/oracle/deleteFromSql.js +8 -0
- package/src/oracle/encodeBoolean.js +7 -0
- package/src/oracle/encodeBuffer.js +7 -0
- package/src/oracle/encodeDate.js +7 -0
- package/src/oracle/formatDateIn.js +5 -0
- package/src/oracle/formatDateOut.js +5 -0
- package/src/oracle/insert.js +23 -0
- package/src/oracle/insertSql.js +73 -0
- package/src/oracle/lastInsertedSql.js +14 -0
- package/src/oracle/limitAndOffset.js +18 -0
- package/src/oracle/mergeSql.js +79 -0
- package/src/oracle/newDatabase.js +128 -0
- package/src/oracle/newInsertCommandCore.js +27 -0
- package/src/oracle/newPool.js +19 -0
- package/src/oracle/newTransaction.js +63 -0
- package/src/oracle/outputInsertedSql.js +5 -0
- package/src/oracle/pool/defaults.js +45 -0
- package/src/oracle/pool/end.js +13 -0
- package/src/oracle/pool/newGenericPool.js +64 -0
- package/src/oracle/replaceParamChar.js +14 -0
- package/src/oracle/selectForUpdateSql.js +3 -0
- package/src/oracle/wrapQuery.js +38 -0
- package/src/patchRow.js +13 -0
- package/src/patchTable.js +317 -0
- package/src/pg/deleteFromSql.js +8 -0
- package/src/pg/encodeBoolean.js +5 -0
- package/src/pg/encodeDate.js +7 -0
- package/src/pg/encodeJSON.js +15 -0
- package/src/pg/formatDateOut.js +5 -0
- package/src/pg/insert.js +14 -0
- package/src/pg/insertSql.js +70 -0
- package/src/pg/lastInsertedSql.js +11 -0
- package/src/pg/limitAndOffset.js +18 -0
- package/src/pg/newDatabase.js +153 -0
- package/src/pg/newPool.js +19 -0
- package/src/pg/newStreamableQuery.js +7 -0
- package/src/pg/newTransaction.js +58 -0
- package/src/pg/pool/defaults.js +45 -0
- package/src/pg/pool/end.js +13 -0
- package/src/pg/pool/newPgPool.js +82 -0
- package/src/pg/replaceParamChar.js +14 -0
- package/src/pg/schema.js +11 -0
- package/src/pg/selectForUpdateSql.js +3 -0
- package/src/pg/wrapQuery.js +33 -0
- package/src/pg/wrapQueryStream.js +20 -0
- package/src/pools.js +17 -0
- package/src/query/negotiateParameters.js +10 -0
- package/src/query/negotiateSql.js +14 -0
- package/src/query/wrapQuery.js +17 -0
- package/src/query.js +13 -0
- package/src/sap/deleteFromSql.js +8 -0
- package/src/sap/encodeBoolean.js +7 -0
- package/src/sap/encodeBuffer.js +7 -0
- package/src/sap/formatDateOut.js +5 -0
- package/src/sap/insert.js +21 -0
- package/src/sap/insertSql.js +64 -0
- package/src/sap/lastInsertedSql.js +12 -0
- package/src/sap/limitAndOffset.js +16 -0
- package/src/sap/mergeSql.js +73 -0
- package/src/sap/newDatabase.js +129 -0
- package/src/sap/newPool.js +19 -0
- package/src/sap/newTransaction.js +69 -0
- package/src/sap/pool/end.js +13 -0
- package/src/sap/selectForUpdateSql.js +3 -0
- package/src/sqlite/deleteFromSql.js +8 -0
- package/src/sqlite/encodeBoolean.js +7 -0
- package/src/sqlite/encodeBuffer.js +7 -0
- package/src/sqlite/insert.js +21 -0
- package/src/sqlite/insertSql.js +64 -0
- package/src/sqlite/lastInsertedSql.js +12 -0
- package/src/sqlite/limitAndOffset.js +18 -0
- package/src/sqlite/newDatabase.js +128 -0
- package/src/sqlite/newPool.js +19 -0
- package/src/sqlite/newTransaction.js +58 -0
- package/src/sqlite/pool/defaults.js +45 -0
- package/src/sqlite/pool/end.js +13 -0
- package/src/sqlite/pool/newGenericPool.js +59 -0
- package/src/sqlite/selectForUpdateSql.js +3 -0
- package/src/sqlite/wrapQuery.js +24 -0
- package/src/table/aggregate.js +9 -0
- package/src/table/begin.js +10 -0
- package/src/table/cascadeDelete.js +11 -0
- package/src/table/cloneStrategy.js +18 -0
- package/src/table/column/binary/newDecode.js +15 -0
- package/src/table/column/binary/newEncode.js +23 -0
- package/src/table/column/binary/purify.js +12 -0
- package/src/table/column/binary.js +12 -0
- package/src/table/column/boolean/newDecode.js +12 -0
- package/src/table/column/boolean/newEncode.js +36 -0
- package/src/table/column/boolean/purify.js +7 -0
- package/src/table/column/boolean.js +14 -0
- package/src/table/column/date/formatOut.js +11 -0
- package/src/table/column/date/newDecode.js +17 -0
- package/src/table/column/date/newEncode.js +47 -0
- package/src/table/column/date/purify.js +17 -0
- package/src/table/column/date/toISOString.js +25 -0
- package/src/table/column/date/tryParseISO.js +14 -0
- package/src/table/column/date.js +14 -0
- package/src/table/column/dateWithTimeZone/newEncode.js +41 -0
- package/src/table/column/dateWithTimeZone.js +14 -0
- package/src/table/column/encodeFilterArg.js +8 -0
- package/src/table/column/equal.js +15 -0
- package/src/table/column/extractAlias.js +7 -0
- package/src/table/column/greaterThan.js +12 -0
- package/src/table/column/greaterThanOrEqual.js +12 -0
- package/src/table/column/guid/newDecode.js +10 -0
- package/src/table/column/guid/newEncode.js +30 -0
- package/src/table/column/guid/purify.js +10 -0
- package/src/table/column/guid.js +12 -0
- package/src/table/column/in.js +24 -0
- package/src/table/column/json/formatOut.js +11 -0
- package/src/table/column/json/newDecode.js +21 -0
- package/src/table/column/json/newEncode.js +41 -0
- package/src/table/column/json/purify.js +7 -0
- package/src/table/column/json.js +22 -0
- package/src/table/column/lessThan.js +12 -0
- package/src/table/column/lessThanOrEqual.js +12 -0
- package/src/table/column/negotiateNextAndFilter.js +7 -0
- package/src/table/column/negotiateNextOrFilter.js +7 -0
- package/src/table/column/negotiateRawSqlFilter.js +74 -0
- package/src/table/column/newBoolean.js +54 -0
- package/src/table/column/newColumn.js +89 -0
- package/src/table/column/newDecodeCore.js +10 -0
- package/src/table/column/notEqual.js +15 -0
- package/src/table/column/numeric/negotiateDefault.js +5 -0
- package/src/table/column/numeric/newDecode.js +16 -0
- package/src/table/column/numeric/newEncode.js +25 -0
- package/src/table/column/numeric/purify.js +12 -0
- package/src/table/column/numeric.js +15 -0
- package/src/table/column/string/contains.js +3 -0
- package/src/table/column/string/containsCore.js +16 -0
- package/src/table/column/string/endsWith.js +3 -0
- package/src/table/column/string/endsWithCore.js +16 -0
- package/src/table/column/string/iContains.js +3 -0
- package/src/table/column/string/iEndsWith.js +3 -0
- package/src/table/column/string/iEqual.js +15 -0
- package/src/table/column/string/iStartsWith.js +3 -0
- package/src/table/column/string/newEncode.js +31 -0
- package/src/table/column/string/purify.js +7 -0
- package/src/table/column/string/startsWith.js +3 -0
- package/src/table/column/string/startsWithCore.js +16 -0
- package/src/table/column/string.js +55 -0
- package/src/table/column.js +154 -0
- package/src/table/commands/beginCommand.js +13 -0
- package/src/table/commands/commitCommand.js +9 -0
- package/src/table/commands/compressChanges.js +25 -0
- package/src/table/commands/delete/createAlias.js +6 -0
- package/src/table/commands/delete/newSingleCommand.js +17 -0
- package/src/table/commands/delete/singleCommand/joinSql.js +26 -0
- package/src/table/commands/delete/singleCommand/newSingleCommandCore.js +19 -0
- package/src/table/commands/delete/singleCommand/selectSql.js +11 -0
- package/src/table/commands/delete/singleCommand/subFilter.js +19 -0
- package/src/table/commands/delete/singleCommand/whereSql.js +25 -0
- package/src/table/commands/getChangeSet.js +6 -0
- package/src/table/commands/insert/getSqlTemplate.js +68 -0
- package/src/table/commands/lastCommandMatches.js +11 -0
- package/src/table/commands/negotiateEndEdit.js +7 -0
- package/src/table/commands/newDeleteCommand.js +23 -0
- package/src/table/commands/newGetLastInsertedCommand.js +49 -0
- package/src/table/commands/newGetLastInsertedCommandCore.js +42 -0
- package/src/table/commands/newInsertAndForgetCommand.js +55 -0
- package/src/table/commands/newInsertCommand.js +56 -0
- package/src/table/commands/newInsertCommandCore.js +27 -0
- package/src/table/commands/newRow.js +51 -0
- package/src/table/commands/newUpdateCommand.js +62 -0
- package/src/table/commands/newUpdateCommandCore.js +45 -0
- package/src/table/commands/pushCommand.js +10 -0
- package/src/table/commands/rollbackCommand.js +13 -0
- package/src/table/commit.js +30 -0
- package/src/table/count.js +29 -0
- package/src/table/createJSONReadStream.js +7 -0
- package/src/table/createJSONReadStreamDefault.js +33 -0
- package/src/table/createJSONReadStreamNative.js +31 -0
- package/src/table/createReadStream.js +24 -0
- package/src/table/createReadStreamCoreNative.js +40 -0
- package/src/table/createReadStreamDefault.js +102 -0
- package/src/table/createReadStreamNative.js +17 -0
- package/src/table/delete.js +20 -0
- package/src/table/deleteSessionContext.js +17 -0
- package/src/table/encodeDbSpecific.js +10 -0
- package/src/table/executeQueries/executeChanges.js +35 -0
- package/src/table/executeQueries/executeQueriesCore.js +12 -0
- package/src/table/executeQueries/executeQuery.js +8 -0
- package/src/table/executeQueries/resolveExecuteQuery.js +57 -0
- package/src/table/executeQueries.js +15 -0
- package/src/table/extractDeleteStrategy.js +9 -0
- package/src/table/fuzzyPromise.js +18 -0
- package/src/table/getById.js +33 -0
- package/src/table/getFirstFromDb.js +10 -0
- package/src/table/getFromDbById.js +17 -0
- package/src/table/getIdArgs.js +14 -0
- package/src/table/getMany.js +26 -0
- package/src/table/getManyDto/newQuery.js +32 -0
- package/src/table/getManyDto/pg/newQuery.js +8 -0
- package/src/table/getManyDto.js +10 -0
- package/src/table/getManyDtoFast/getSubRows.js +172 -0
- package/src/table/getManyDtoFast/newQuery.js +8 -0
- package/src/table/getManyDtoFast/newQueryCore.js +18 -0
- package/src/table/getManyDtoFast/query/newSingleQuery.js +20 -0
- package/src/table/getManyDtoFast/query/newSubQueries/joinLegToQuery.js +18 -0
- package/src/table/getManyDtoFast/query/newSubQueries/manyLegToQuery.js +20 -0
- package/src/table/getManyDtoFast/query/newSubQueries/oneLegToQuery.js +21 -0
- package/src/table/getManyDtoFast/query/newSubQueries.js +47 -0
- package/src/table/getManyDtoFast/query/singleQuery/newShallowColumnSql.js +21 -0
- package/src/table/getSessionContext.js +10 -0
- package/src/table/getSessionSingleton.js +5 -0
- package/src/table/groupBy/newQuery.js +25 -0
- package/src/table/groupBy.js +65 -0
- package/src/table/hasMany.js +33 -0
- package/src/table/hasOne.js +33 -0
- package/src/table/insert.js +91 -0
- package/src/table/insertDefault.js +88 -0
- package/src/table/join.js +42 -0
- package/src/table/joinRelation/getRelatives.js +64 -0
- package/src/table/log.js +39 -0
- package/src/table/negotiateAddStrategy.js +20 -0
- package/src/table/negotiateExpandInverse.js +13 -0
- package/src/table/newCache.js +96 -0
- package/src/table/newCascadeDeleteStrategy.js +30 -0
- package/src/table/newGetRelated.js +21 -0
- package/src/table/newJoinRelation.js +117 -0
- package/src/table/newManyRelation.js +61 -0
- package/src/table/newOneRelation.js +61 -0
- package/src/table/newPrimaryKeyFilter.js +13 -0
- package/src/table/newQuery.js +18 -0
- package/src/table/newRelatedTable.js +100 -0
- package/src/table/newRowCache.js +106 -0
- package/src/table/newThrow.js +11 -0
- package/src/table/nullPromise.js +1 -0
- package/src/table/objectToCallback.js +7 -0
- package/src/table/oneRelation/getRelatives.js +45 -0
- package/src/table/popChanges.js +19 -0
- package/src/table/promise.js +14 -0
- package/src/table/purifyStrategy.js +49 -0
- package/src/table/query/extractFilter.js +9 -0
- package/src/table/query/extractLimit.js +11 -0
- package/src/table/query/extractLimitQuery.js +23 -0
- package/src/table/query/extractOffset.js +11 -0
- package/src/table/query/extractOrderBy.js +57 -0
- package/src/table/query/extractSql.js +10 -0
- package/src/table/query/newParameterized.js +38 -0
- package/src/table/query/newSingleQuery.js +23 -0
- package/src/table/query/parameterized/extractParameters.js +8 -0
- package/src/table/query/singleQuery/columnSql/joinLegToColumnSql.js +16 -0
- package/src/table/query/singleQuery/columnSql/newJoinedColumnSql.js +27 -0
- package/src/table/query/singleQuery/columnSql/newShallowColumnSql.js +37 -0
- package/src/table/query/singleQuery/joinSql/joinLegToJoinSql.js +13 -0
- package/src/table/query/singleQuery/joinSql/joinLegToShallowJoinSql.js +9 -0
- package/src/table/query/singleQuery/joinSql/newDiscriminatorSql.js +11 -0
- package/src/table/query/singleQuery/joinSql/newShallowJoinSql.js +9 -0
- package/src/table/query/singleQuery/joinSql/newShallowJoinSqlCore.js +25 -0
- package/src/table/query/singleQuery/joinSql/oneLegToJoinSql.js +13 -0
- package/src/table/query/singleQuery/joinSql/oneLegToShallowJoinSql.js +10 -0
- package/src/table/query/singleQuery/negotiateExclusive.js +11 -0
- package/src/table/query/singleQuery/negotiateLimit.js +10 -0
- package/src/table/query/singleQuery/newColumnSql.js +8 -0
- package/src/table/query/singleQuery/newDiscriminatorSql.js +33 -0
- package/src/table/query/singleQuery/newJoinSql.js +41 -0
- package/src/table/query/singleQuery/newQueryContext.js +20 -0
- package/src/table/query/singleQuery/newWhereSql.js +19 -0
- package/src/table/readStream/extractLimit.js +7 -0
- package/src/table/readStream/extractOrderBy.js +55 -0
- package/src/table/readStream/mySql/newQuery.js +16 -0
- package/src/table/readStream/mySql/query/newSingleQuery.js +21 -0
- package/src/table/readStream/mySql/query/newSubQueries/joinLegToQuery.js +19 -0
- package/src/table/readStream/mySql/query/newSubQueries/manyLegToQuery.js +22 -0
- package/src/table/readStream/mySql/query/newSubQueries/newQueryCore.js +9 -0
- package/src/table/readStream/mySql/query/newSubQueries/newSingleQueryCore.js +18 -0
- package/src/table/readStream/mySql/query/newSubQueries/oneLegToQuery.js +22 -0
- package/src/table/readStream/mySql/query/newSubQueries.js +47 -0
- package/src/table/readStream/mySql/query/singleQuery/newShallowColumnSql.js +17 -0
- package/src/table/readStream/newQuery.js +32 -0
- package/src/table/readStream/newQueryStream.js +8 -0
- package/src/table/readStream/pg/newQuery.js +8 -0
- package/src/table/readStream/pg/newQueryCore.js +17 -0
- package/src/table/readStream/pg/query/newSingleQuery.js +19 -0
- package/src/table/readStream/pg/query/newSubQueries/joinLegToQuery.js +19 -0
- package/src/table/readStream/pg/query/newSubQueries/manyLegToQuery.js +22 -0
- package/src/table/readStream/pg/query/newSubQueries/oneLegToQuery.js +19 -0
- package/src/table/readStream/pg/query/newSubQueries.js +47 -0
- package/src/table/readStream/pg/query/singleQuery/newShallowColumnSql.js +19 -0
- package/src/table/readStreamDefault/createBatchFilter.js +39 -0
- package/src/table/relatedTable/aggregate/aggregateJoinSql.js +37 -0
- package/src/table/relatedTable/aggregate/joinSql.js +38 -0
- package/src/table/relatedTable/aggregate.js +48 -0
- package/src/table/relatedTable/all.js +24 -0
- package/src/table/relatedTable/any.js +70 -0
- package/src/table/relatedTable/childColumn.js +61 -0
- package/src/table/relatedTable/columnAggregate.js +16 -0
- package/src/table/relatedTable/columnAggregateGroup.js +59 -0
- package/src/table/relatedTable/joinSql.js +40 -0
- package/src/table/relatedTable/joinSqlArray.js +32 -0
- package/src/table/relatedTable/none.js +22 -0
- package/src/table/relatedTable/relatedColumn.js +49 -0
- package/src/table/relatedTable/relationFilter.js +16 -0
- package/src/table/relatedTable/selectSql.js +11 -0
- package/src/table/relatedTable/subFilter.js +16 -0
- package/src/table/relatedTable/where.js +50 -0
- package/src/table/relatedTable/whereSql.js +41 -0
- package/src/table/relation/manyCache/extractParentKey.js +17 -0
- package/src/table/relation/manyCache/synchronizeAdded.js +13 -0
- package/src/table/relation/manyCache/synchronizeChanged.js +31 -0
- package/src/table/relation/manyCache/synchronizeRemoved.js +13 -0
- package/src/table/relation/newExpanderCache.js +7 -0
- package/src/table/relation/newForeignKeyFilter.js +20 -0
- package/src/table/relation/newJoinLeg.js +23 -0
- package/src/table/relation/newManyCache.js +57 -0
- package/src/table/relation/newManyCacheCore.js +53 -0
- package/src/table/relation/newManyLeg.js +15 -0
- package/src/table/relation/newOneCache.js +28 -0
- package/src/table/relation/newOneLeg.js +25 -0
- package/src/table/releaseDbClient.js +15 -0
- package/src/table/resultToPromise.js +8 -0
- package/src/table/resultToRows/dbRowToRow.js +51 -0
- package/src/table/resultToRows/dbRowsToRows.js +13 -0
- package/src/table/resultToRows/decodeDbRow.js +25 -0
- package/src/table/resultToRows/delete/removeFromCache.js +33 -0
- package/src/table/resultToRows/delete.js +31 -0
- package/src/table/resultToRows/negotiateQueryContext.js +6 -0
- package/src/table/resultToRows/newDecodeDbRow.js +262 -0
- package/src/table/resultToRows/toDto/createDto.js +20 -0
- package/src/table/resultToRows/toDto/extractStrategy.js +41 -0
- package/src/table/resultToRows/toDto.js +92 -0
- package/src/table/resultToRows.js +37 -0
- package/src/table/rollback.js +31 -0
- package/src/table/rowArray/negotiateNextTick.js +11 -0
- package/src/table/rowArray/orderBy.js +51 -0
- package/src/table/rowArray.js +62 -0
- package/src/table/setSessionSingleton.js +5 -0
- package/src/table/strategyToSpan.js +49 -0
- package/src/table/tryGetById.js +13 -0
- package/src/table/tryGetFirstFromDb.js +23 -0
- package/src/table/tryGetFromCacheById.js +12 -0
- package/src/table/tryGetFromDbById/extractStrategy.js +9 -0
- package/src/table/tryGetFromDbById.js +19 -0
- package/src/table/tryGetSessionContext.js +16 -0
- package/src/table/tryReleaseDbClient.js +14 -0
- package/src/table/updateField.js +12 -0
- package/src/table/where.js +12 -0
- package/src/table.js +174 -0
- package/src/tedious/deleteFromSql.js +8 -0
- package/src/tedious/encodeBoolean.js +7 -0
- package/src/tedious/encodeBuffer.js +7 -0
- package/src/tedious/formatDateOut.js +5 -0
- package/src/tedious/formatJSONOut.js +5 -0
- package/src/tedious/getManyDto/newQuery.js +8 -0
- package/src/tedious/getManyDto/newQueryCore.js +18 -0
- package/src/tedious/getManyDto/query/newSingleQuery.js +29 -0
- package/src/tedious/getManyDto/query/newSubQueries/joinLegToQuery.js +16 -0
- package/src/tedious/getManyDto/query/newSubQueries/manyLegToQuery.js +16 -0
- package/src/tedious/getManyDto/query/newSubQueries/oneLegToQuery.js +19 -0
- package/src/tedious/getManyDto/query/newSubQueries.js +48 -0
- package/src/tedious/getManyDto/query/singleQuery/newShallowColumnSql.js +34 -0
- package/src/tedious/getManyDto.js +27 -0
- package/src/tedious/insert.js +13 -0
- package/src/tedious/insertSql.js +70 -0
- package/src/tedious/limitAndOffset.js +16 -0
- package/src/tedious/mergeSql.js +76 -0
- package/src/tedious/newDatabase.js +129 -0
- package/src/tedious/newPool.js +19 -0
- package/src/tedious/newTransaction.js +72 -0
- package/src/tedious/outputInsertedSql.js +11 -0
- package/src/tedious/pool/defaults.js +45 -0
- package/src/tedious/pool/end.js +13 -0
- package/src/tedious/pool/newGenericPool.js +71 -0
- package/src/tedious/pool/parseConnectionString.js +40 -0
- package/src/tedious/selectForUpdateSql.js +3 -0
- package/src/tedious/wrapQuery.js +112 -0
- package/src/toCompareObject.js +41 -0
- package/src/useHook.js +9 -0
- package/src/validateDeleteAllowed.js +49 -0
- package/src/validateDeleteConflict.js +92 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
const _newTable = require('../table');
|
|
2
|
+
const createProviders = require('./createProviders');
|
|
3
|
+
|
|
4
|
+
function mapRoot(index, fn) {
|
|
5
|
+
|
|
6
|
+
const providers = createProviders(index);
|
|
7
|
+
|
|
8
|
+
return map(index, context, providers, fn);
|
|
9
|
+
|
|
10
|
+
function context(arg) {
|
|
11
|
+
|
|
12
|
+
const tables = {};
|
|
13
|
+
for (let name in context) {
|
|
14
|
+
if (context[name] && context[name]._dbName)
|
|
15
|
+
tables[name] = context[name];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (arg && arg.db && typeof arg.db === 'function') {
|
|
19
|
+
return index({
|
|
20
|
+
...arg,
|
|
21
|
+
db: providers(arg.db),
|
|
22
|
+
tables, providers
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else
|
|
26
|
+
return index({
|
|
27
|
+
...arg, tables, providers
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
function map(index, context, providers, fn) {
|
|
34
|
+
let next = fn({ table: newTable, ...context });
|
|
35
|
+
|
|
36
|
+
for (let name in next) {
|
|
37
|
+
if (next[name] && next[name]._dbName) {
|
|
38
|
+
context[name] = next[name];
|
|
39
|
+
context[name].map = mapTable.bind(null, context[name]);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
context.map = map.bind(null, index, context, providers);
|
|
43
|
+
context.pg = connect.bind(null, 'pg');
|
|
44
|
+
context.postgres = connect.bind(null, 'pg');
|
|
45
|
+
context.mssql = connect.bind(null, 'mssql');
|
|
46
|
+
context.mssqlNative = connect.bind(null, 'mssqlNative');
|
|
47
|
+
context.mysql = connect.bind(null, 'mysql');
|
|
48
|
+
context.sap = connect.bind(null, 'sap');
|
|
49
|
+
context.oracle = connect.bind(null, 'oracle');
|
|
50
|
+
context.sqlite = connect.bind(null, 'sqlite');
|
|
51
|
+
context.http = function(url) {
|
|
52
|
+
return index({ db: url, providers});
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
function connect(name, ...args) {
|
|
56
|
+
const provider = index[name];
|
|
57
|
+
const pool = provider.apply(null, args);
|
|
58
|
+
|
|
59
|
+
const tables = {};
|
|
60
|
+
for (let name in context) {
|
|
61
|
+
if (context[name] && context[name]._dbName)
|
|
62
|
+
tables[name] = context[name];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return index({ db: pool, tables, providers });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return context;
|
|
69
|
+
|
|
70
|
+
function newTable() {
|
|
71
|
+
let table = _newTable.apply(null, arguments);
|
|
72
|
+
table.map = mapTable.bind(null, table);
|
|
73
|
+
return table;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function mapTable(table, fn) {
|
|
78
|
+
let next = fn({ column: table.column, primaryColumn: table.primaryColumn, references: table.join, hasMany, hasOne });
|
|
79
|
+
for (let name in next) {
|
|
80
|
+
if (next[name].as)
|
|
81
|
+
next[name] = next[name].as(name);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function hasMany(to) {
|
|
85
|
+
if (!to)
|
|
86
|
+
throw new Error('Missing \'to\' table');
|
|
87
|
+
return { by };
|
|
88
|
+
|
|
89
|
+
function by() {
|
|
90
|
+
const join = to.join(table).by.apply(null, arguments);
|
|
91
|
+
return table.hasMany(join);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function hasOne(to) {
|
|
96
|
+
if (!to)
|
|
97
|
+
throw new Error('Missing \'to\' table');
|
|
98
|
+
return { by };
|
|
99
|
+
|
|
100
|
+
function by() {
|
|
101
|
+
const join = to.join(table).by.apply(null, arguments);
|
|
102
|
+
return table.hasOne(join);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return table;
|
|
107
|
+
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module.exports = mapRoot;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const fs = require('fs').promises;
|
|
2
|
+
|
|
3
|
+
async function merge() {
|
|
4
|
+
let data1 = await fs.readFile('./src/client/self.js', 'utf8');
|
|
5
|
+
let data2 = await fs.readFile('./src/client/index.mjs', 'utf8');
|
|
6
|
+
await fs.writeFile('./src/client/index.mjs', data1 + data2);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
merge();
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
const _axios = require('axios');
|
|
2
|
+
|
|
3
|
+
function httpAdapter(baseURL, path, axiosInterceptor) {
|
|
4
|
+
//@ts-ignore
|
|
5
|
+
const axios = _axios.default ? _axios.default.create({ baseURL }) : _axios.create({ baseURL });
|
|
6
|
+
axiosInterceptor.applyTo(axios);
|
|
7
|
+
|
|
8
|
+
let c = {
|
|
9
|
+
get,
|
|
10
|
+
post,
|
|
11
|
+
patch,
|
|
12
|
+
query,
|
|
13
|
+
express
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return c;
|
|
17
|
+
|
|
18
|
+
async function get() {
|
|
19
|
+
try {
|
|
20
|
+
const headers = { 'Content-Type': 'application/json', 'Accept': 'application/json' };
|
|
21
|
+
const res = await axios.request(path, { headers, method: 'get' });
|
|
22
|
+
return res.data;
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
if (e.response?.data)
|
|
26
|
+
throw new Error(e.response?.data.replace(/^Error: /, ''));
|
|
27
|
+
else
|
|
28
|
+
throw e;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async function patch(body) {
|
|
34
|
+
try {
|
|
35
|
+
|
|
36
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
37
|
+
const res = await axios.request(path, { headers, method: 'patch', data: body });
|
|
38
|
+
return res.data;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
if (e.response?.data)
|
|
42
|
+
throw new Error(e.response?.data.replace(/^Error: /, ''));
|
|
43
|
+
else
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async function post(body) {
|
|
51
|
+
try {
|
|
52
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
53
|
+
const res = await axios.request(path, { headers, method: 'post', data: body });
|
|
54
|
+
return res.data;
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
if (e.response?.data)
|
|
58
|
+
throw new Error(e.response?.data.replace(/^Error: /, ''));
|
|
59
|
+
else throw e;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
function query() {
|
|
65
|
+
throw new Error('Queries are not supported through http');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function express() {
|
|
69
|
+
throw new Error('Hosting in express is not supported on the client side');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function netAdapter(url, tableName, { axios, tableOptions }) {
|
|
74
|
+
|
|
75
|
+
let c = {
|
|
76
|
+
get,
|
|
77
|
+
post,
|
|
78
|
+
patch,
|
|
79
|
+
query
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
return c;
|
|
83
|
+
|
|
84
|
+
async function get() {
|
|
85
|
+
const adapter = await getInnerAdapter();
|
|
86
|
+
return adapter.get.apply(null, arguments);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function patch(_body) {
|
|
90
|
+
const adapter = await getInnerAdapter();
|
|
91
|
+
return adapter.patch.apply(null, arguments);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function post(_body) {
|
|
95
|
+
const adapter = await getInnerAdapter();
|
|
96
|
+
return adapter.post.apply(null, arguments);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async function query() {
|
|
100
|
+
const adapter = await getInnerAdapter();
|
|
101
|
+
return adapter.query.apply(null, arguments);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function getInnerAdapter() {
|
|
105
|
+
const db = await getDb();
|
|
106
|
+
if (typeof db === 'string') {
|
|
107
|
+
return httpAdapter(db, `?table=${tableName}`, axios);
|
|
108
|
+
}
|
|
109
|
+
else if (db && db.transaction) {
|
|
110
|
+
return db.hostLocal({ ...tableOptions, db, table: url });
|
|
111
|
+
}
|
|
112
|
+
else
|
|
113
|
+
throw new Error('Invalid arguments');
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function getDb() {
|
|
117
|
+
let db = tableOptions.db;
|
|
118
|
+
if (db.transaction)
|
|
119
|
+
return db;
|
|
120
|
+
if (typeof db === 'function') {
|
|
121
|
+
let dbPromise = db();
|
|
122
|
+
if (dbPromise.then)
|
|
123
|
+
db = await dbPromise;
|
|
124
|
+
else
|
|
125
|
+
db = dbPromise;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return db;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
module.exports = netAdapter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
2
|
+
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
input: './src/client/index.js',
|
|
6
|
+
output: {
|
|
7
|
+
file: './src/client/index.mjs',
|
|
8
|
+
format: 'esm'
|
|
9
|
+
},
|
|
10
|
+
plugins: [commonjs(), nodeResolve({browser: true})],
|
|
11
|
+
external: ['vue']
|
|
12
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
let dateToISOString = require('../dateToISOString');
|
|
2
|
+
const isNode = (typeof window === 'undefined');
|
|
3
|
+
|
|
4
|
+
function stringify(value) {
|
|
5
|
+
return JSON.stringify(value, replacer);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function replacer(key, value) {
|
|
9
|
+
if (isNode && isNodeBuffer(value))
|
|
10
|
+
return value.toString('base64');
|
|
11
|
+
// @ts-ignore
|
|
12
|
+
else if (value instanceof Date && !isNaN(value))
|
|
13
|
+
return dateToISOString(value);
|
|
14
|
+
else
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isNodeBuffer(object) {
|
|
19
|
+
return Buffer.isBuffer(object);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = stringify;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const stringify = require('./stringify');
|
|
2
|
+
const { v4: uuid } = require('uuid');
|
|
3
|
+
|
|
4
|
+
function toKeyPositionMap(rows, options) {
|
|
5
|
+
return rows.reduce((map, element, i) => {
|
|
6
|
+
if (options && options.keys && element === Object(element)) {
|
|
7
|
+
let key = [];
|
|
8
|
+
for (let i = 0; i < options.keys.length; i++) {
|
|
9
|
+
let keyName = options.keys[i].name;
|
|
10
|
+
key.push(negotiateTempKey(element[keyName]));
|
|
11
|
+
}
|
|
12
|
+
map[stringify(key)] = i;
|
|
13
|
+
}
|
|
14
|
+
else if ('id' in element)
|
|
15
|
+
map[stringify(element.id)] = i;
|
|
16
|
+
else
|
|
17
|
+
map[i] = i;
|
|
18
|
+
return map;
|
|
19
|
+
}, {});
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function negotiateTempKey(value) {
|
|
24
|
+
if (value === undefined)
|
|
25
|
+
return `~${uuid()}`;
|
|
26
|
+
else
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
module.exports = toKeyPositionMap;
|
package/src/clsTest.js
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
let cls = require('node-cls');
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const log = (str) => fs.writeSync(1, `${str}\n`);
|
|
4
|
+
|
|
5
|
+
function begin(id) {
|
|
6
|
+
return new Promise((resolve) => {
|
|
7
|
+
let context = cls.get();
|
|
8
|
+
context.id = id;
|
|
9
|
+
resolve();
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function getById() {
|
|
14
|
+
return new Promise((resolve) => {
|
|
15
|
+
let context = cls.get();
|
|
16
|
+
context.id;
|
|
17
|
+
resolve(context.id);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function getFromDb() {
|
|
22
|
+
let c = cls.create();
|
|
23
|
+
await c.start();
|
|
24
|
+
await begin(1);
|
|
25
|
+
await new Promise((resolve) => {
|
|
26
|
+
setTimeout(resolve(), 500);
|
|
27
|
+
});
|
|
28
|
+
await getFromDb2();
|
|
29
|
+
|
|
30
|
+
let c3 = cls.create();
|
|
31
|
+
await c3.start();
|
|
32
|
+
await begin(3);
|
|
33
|
+
let id3 = await getById();
|
|
34
|
+
if (id3 !== 3)
|
|
35
|
+
throw new Error('3 Unexpected context id : ' + id3);
|
|
36
|
+
cls.exit();
|
|
37
|
+
|
|
38
|
+
await getFromDb3();
|
|
39
|
+
|
|
40
|
+
let id = await getById();
|
|
41
|
+
if (id !== 1)
|
|
42
|
+
throw new Error('1 Unexpected context id : ' + id);
|
|
43
|
+
cls.exit();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getFromDb2() {
|
|
47
|
+
return new Promise((resolve) => {
|
|
48
|
+
setTimeout(async () => {
|
|
49
|
+
let c2 = cls.create();
|
|
50
|
+
await c2.start();
|
|
51
|
+
await begin(2);
|
|
52
|
+
let id2 = await getById();
|
|
53
|
+
if (id2 !== 2)
|
|
54
|
+
throw new Error('2 Unexpected context id : ' + id2);
|
|
55
|
+
id2 = cls.active.id;
|
|
56
|
+
if (id2 !== 2)
|
|
57
|
+
throw new Error('2 Unexpected context id : ' + id2);
|
|
58
|
+
cls.exit();
|
|
59
|
+
resolve();
|
|
60
|
+
}, 500);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function getFromDb3() {
|
|
65
|
+
let c3 = cls.create();
|
|
66
|
+
await c3.start();
|
|
67
|
+
await begin(3);
|
|
68
|
+
let id3 = await getById();
|
|
69
|
+
if (id3 !== 3)
|
|
70
|
+
throw new Error('3 Unexpected context id : ' + id3);
|
|
71
|
+
cls.exit();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
async function testStart() {
|
|
76
|
+
await getFromDb();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
testStart().then(() => log('done'), (e) => log(e.stack));
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
function negotiateForwardProperty(oldDomain, newDomain, propertyName) {
|
|
2
|
+
if(newDomain[propertyName]) return;
|
|
3
|
+
if (propertyName === 'rdb') return;
|
|
4
|
+
Object.defineProperty(newDomain, propertyName, {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: createGetter(oldDomain, propertyName),
|
|
7
|
+
set: createSetter(oldDomain, propertyName)
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function createGetter(oldDomain, propName) {
|
|
12
|
+
return function() {
|
|
13
|
+
return oldDomain[propName];
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function createSetter(oldDomain, propName) {
|
|
18
|
+
return function(value) {
|
|
19
|
+
oldDomain[propName] = value;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = negotiateForwardProperty;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
let useHook = require('./useHook');
|
|
2
|
+
let cls;
|
|
3
|
+
var Domain = require('domain');
|
|
4
|
+
var negotiateForwardProperty = require('./createDomain/negotiateForwardProperty');
|
|
5
|
+
|
|
6
|
+
function createDomain() {
|
|
7
|
+
var oldDomain = Domain.active || {};
|
|
8
|
+
var domain = Domain.create();
|
|
9
|
+
var ownProperties = Object.getOwnPropertyNames(oldDomain);
|
|
10
|
+
ownProperties.forEach(function(propName) {
|
|
11
|
+
negotiateForwardProperty(oldDomain, domain, propName);
|
|
12
|
+
});
|
|
13
|
+
return domain;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function createOnContext() {
|
|
17
|
+
if (!cls)
|
|
18
|
+
cls = require('node-cls');
|
|
19
|
+
return cls.create('rdb');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
function _createDomain() {
|
|
24
|
+
if (useHook())
|
|
25
|
+
return createOnContext();
|
|
26
|
+
else
|
|
27
|
+
return createDomain();
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = _createDomain;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function dateToISOString(date) {
|
|
2
|
+
let tzo = -date.getTimezoneOffset();
|
|
3
|
+
let dif = tzo >= 0 ? '+' : '-';
|
|
4
|
+
|
|
5
|
+
function pad(num) {
|
|
6
|
+
let norm = Math.floor(Math.abs(num));
|
|
7
|
+
return (norm < 10 ? '0' : '') + norm;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function padMilli(d) {
|
|
11
|
+
return (d.getMilliseconds() + '').padStart(3, '0');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return date.getFullYear() +
|
|
15
|
+
'-' + pad(date.getMonth() + 1) +
|
|
16
|
+
'-' + pad(date.getDate()) +
|
|
17
|
+
'T' + pad(date.getHours()) +
|
|
18
|
+
':' + pad(date.getMinutes()) +
|
|
19
|
+
':' + pad(date.getSeconds()) +
|
|
20
|
+
'.' + padMilli(date) +
|
|
21
|
+
dif + pad(tzo / 60) +
|
|
22
|
+
':' + pad(tzo % 60);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = dateToISOString;
|
package/src/emitEvent.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
function emitEvent() {
|
|
2
|
+
var callbacks = [];
|
|
3
|
+
var emit = function() {
|
|
4
|
+
|
|
5
|
+
var copy = callbacks.slice(0, callbacks.length);
|
|
6
|
+
var result = [];
|
|
7
|
+
for (var i = 0; i < copy.length; i++) {
|
|
8
|
+
var callback = copy[i];
|
|
9
|
+
result.push(callback.apply(null,arguments));
|
|
10
|
+
}
|
|
11
|
+
return result;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
emit.add = function(callback) {
|
|
15
|
+
callbacks.push(callback);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
emit.tryAdd = function(callback) {
|
|
19
|
+
if (callback)
|
|
20
|
+
emit.add(callback);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
emit.remove = function(callback) {
|
|
24
|
+
for (var i = 0; i < callbacks.length; i++) {
|
|
25
|
+
if(callbacks[i] === callback){
|
|
26
|
+
callbacks.splice(i,1);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
emit.tryRemove = function(callback) {
|
|
33
|
+
if(callback)
|
|
34
|
+
emit.remove(callback);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
emit.clear = function() {
|
|
38
|
+
callbacks.splice(0, callbacks.length);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
emit.callbacks = callbacks;
|
|
42
|
+
|
|
43
|
+
return emit;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = emitEvent;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var negotiateRawSqlFilter = require('./table/column/negotiateRawSqlFilter');
|
|
2
|
+
var parameterized = require('./table/query/newParameterized')('');
|
|
3
|
+
function emptyFilter() {
|
|
4
|
+
return emptyFilter.and.apply(null, arguments);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
emptyFilter.sql = parameterized.sql;
|
|
8
|
+
emptyFilter.parameters = parameterized.parameters;
|
|
9
|
+
|
|
10
|
+
emptyFilter.and = function(other) {
|
|
11
|
+
other = negotiateRawSqlFilter(other);
|
|
12
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
13
|
+
other = other.and(arguments[i]);
|
|
14
|
+
}
|
|
15
|
+
return other;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
emptyFilter.or = function(other) {
|
|
19
|
+
other = negotiateRawSqlFilter(other);
|
|
20
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
21
|
+
other = other.or(arguments[i]);
|
|
22
|
+
}
|
|
23
|
+
return other;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
emptyFilter.not = function(other) {
|
|
27
|
+
other = negotiateRawSqlFilter(other).not();
|
|
28
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
29
|
+
other = other.and(arguments[i]);
|
|
30
|
+
}
|
|
31
|
+
return other;
|
|
32
|
+
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
module.exports = emptyFilter;
|
package/src/flags.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function fromCompareObject(object) {
|
|
2
|
+
if (object === null || object === undefined) return object;
|
|
3
|
+
if (object.__patchType === 'Array') {
|
|
4
|
+
let copy = [];
|
|
5
|
+
let i = 0;
|
|
6
|
+
for (let id in object) {
|
|
7
|
+
if (id !== '__patchType') {
|
|
8
|
+
copy[i] = fromCompareObject(object[id]);
|
|
9
|
+
i++;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
return copy;
|
|
13
|
+
} else if (object === Object(object)) {
|
|
14
|
+
let copy = {};
|
|
15
|
+
for (let name in object) {
|
|
16
|
+
if (name !== '__patchType')
|
|
17
|
+
copy[name] = fromCompareObject(object[name]);
|
|
18
|
+
}
|
|
19
|
+
return copy;
|
|
20
|
+
}
|
|
21
|
+
return object;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = fromCompareObject;
|