@payloadcms/db-postgres 3.0.0-beta.9 → 3.0.0-beta.90

Sign up to get free protection for your applications and to get access to all the features.
Files changed (366) hide show
  1. package/README.md +1 -1
  2. package/dist/connect.d.ts +1 -1
  3. package/dist/connect.d.ts.map +1 -1
  4. package/dist/connect.js +22 -13
  5. package/dist/connect.js.map +1 -1
  6. package/dist/exports/migration-utils.d.ts +2 -0
  7. package/dist/exports/migration-utils.d.ts.map +1 -0
  8. package/dist/exports/migration-utils.js +3 -0
  9. package/dist/exports/migration-utils.js.map +1 -0
  10. package/dist/index.d.ts +3 -3
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +49 -75
  13. package/dist/index.js.map +1 -1
  14. package/dist/predefinedMigrations/relationships-v2-v3.d.ts +4 -0
  15. package/dist/predefinedMigrations/relationships-v2-v3.d.ts.map +1 -0
  16. package/dist/predefinedMigrations/relationships-v2-v3.js.map +1 -0
  17. package/dist/predefinedMigrations/relationships-v2-v3.mjs +11 -0
  18. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +20 -0
  19. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -0
  20. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +169 -0
  21. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -0
  22. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts +11 -0
  23. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.d.ts.map +1 -0
  24. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js +191 -0
  25. package/dist/predefinedMigrations/v2-v3/fetchAndResave/traverseFields.js.map +1 -0
  26. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts +3 -0
  27. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.d.ts.map +1 -0
  28. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js +56 -0
  29. package/dist/predefinedMigrations/v2-v3/groupUpSQLStatements.js.map +1 -0
  30. package/dist/predefinedMigrations/v2-v3/index.d.ts +23 -0
  31. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -0
  32. package/dist/predefinedMigrations/v2-v3/index.js +211 -0
  33. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -0
  34. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +20 -0
  35. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -0
  36. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js +57 -0
  37. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -0
  38. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +23 -0
  39. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -0
  40. package/dist/predefinedMigrations/v2-v3/traverseFields.js +85 -0
  41. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -0
  42. package/dist/predefinedMigrations/v2-v3/types.d.ts +9 -0
  43. package/dist/predefinedMigrations/v2-v3/types.d.ts.map +1 -0
  44. package/dist/predefinedMigrations/v2-v3/types.js +6 -0
  45. package/dist/predefinedMigrations/v2-v3/types.js.map +1 -0
  46. package/dist/types.d.ts +42 -80
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/types.js.map +1 -1
  49. package/package.json +37 -32
  50. package/dist/create.d.ts +0 -3
  51. package/dist/create.d.ts.map +0 -1
  52. package/dist/create.js +0 -21
  53. package/dist/create.js.map +0 -1
  54. package/dist/createGlobal.d.ts +0 -5
  55. package/dist/createGlobal.d.ts.map +0 -1
  56. package/dist/createGlobal.js +0 -21
  57. package/dist/createGlobal.js.map +0 -1
  58. package/dist/createGlobalVersion.d.ts +0 -6
  59. package/dist/createGlobalVersion.d.ts.map +0 -1
  60. package/dist/createGlobalVersion.js +0 -37
  61. package/dist/createGlobalVersion.js.map +0 -1
  62. package/dist/createMigration.d.ts +0 -3
  63. package/dist/createMigration.d.ts.map +0 -1
  64. package/dist/createMigration.js +0 -81
  65. package/dist/createMigration.js.map +0 -1
  66. package/dist/createVersion.d.ts +0 -5
  67. package/dist/createVersion.d.ts.map +0 -1
  68. package/dist/createVersion.js +0 -48
  69. package/dist/createVersion.js.map +0 -1
  70. package/dist/deleteMany.d.ts +0 -3
  71. package/dist/deleteMany.d.ts.map +0 -1
  72. package/dist/deleteMany.js +0 -31
  73. package/dist/deleteMany.js.map +0 -1
  74. package/dist/deleteOne.d.ts +0 -3
  75. package/dist/deleteOne.d.ts.map +0 -1
  76. package/dist/deleteOne.js +0 -62
  77. package/dist/deleteOne.js.map +0 -1
  78. package/dist/deleteVersions.d.ts +0 -3
  79. package/dist/deleteVersions.d.ts.map +0 -1
  80. package/dist/deleteVersions.js +0 -35
  81. package/dist/deleteVersions.js.map +0 -1
  82. package/dist/destroy.d.ts +0 -3
  83. package/dist/destroy.d.ts.map +0 -1
  84. package/dist/destroy.js +0 -11
  85. package/dist/destroy.js.map +0 -1
  86. package/dist/find/buildFindManyArgs.d.ts +0 -13
  87. package/dist/find/buildFindManyArgs.d.ts.map +0 -1
  88. package/dist/find/buildFindManyArgs.js +0 -64
  89. package/dist/find/buildFindManyArgs.js.map +0 -1
  90. package/dist/find/chainMethods.d.ts +0 -16
  91. package/dist/find/chainMethods.d.ts.map +0 -1
  92. package/dist/find/chainMethods.js +0 -12
  93. package/dist/find/chainMethods.js.map +0 -1
  94. package/dist/find/findMany.d.ts +0 -22
  95. package/dist/find/findMany.d.ts.map +0 -1
  96. package/dist/find/findMany.js +0 -163
  97. package/dist/find/findMany.js.map +0 -1
  98. package/dist/find/traverseFields.d.ts +0 -16
  99. package/dist/find/traverseFields.d.ts.map +0 -1
  100. package/dist/find/traverseFields.js +0 -154
  101. package/dist/find/traverseFields.js.map +0 -1
  102. package/dist/find.d.ts +0 -3
  103. package/dist/find.d.ts.map +0 -1
  104. package/dist/find.js +0 -24
  105. package/dist/find.js.map +0 -1
  106. package/dist/findGlobal.d.ts +0 -3
  107. package/dist/findGlobal.d.ts.map +0 -1
  108. package/dist/findGlobal.js +0 -26
  109. package/dist/findGlobal.js.map +0 -1
  110. package/dist/findGlobalVersions.d.ts +0 -3
  111. package/dist/findGlobalVersions.d.ts.map +0 -1
  112. package/dist/findGlobalVersions.js +0 -28
  113. package/dist/findGlobalVersions.js.map +0 -1
  114. package/dist/findOne.d.ts +0 -5
  115. package/dist/findOne.d.ts.map +0 -1
  116. package/dist/findOne.js +0 -24
  117. package/dist/findOne.js.map +0 -1
  118. package/dist/findVersions.d.ts +0 -3
  119. package/dist/findVersions.d.ts.map +0 -1
  120. package/dist/findVersions.js +0 -28
  121. package/dist/findVersions.js.map +0 -1
  122. package/dist/init.d.ts +0 -3
  123. package/dist/init.d.ts.map +0 -1
  124. package/dist/init.js +0 -94
  125. package/dist/init.js.map +0 -1
  126. package/dist/migrate.d.ts +0 -3
  127. package/dist/migrate.d.ts.map +0 -1
  128. package/dist/migrate.js +0 -99
  129. package/dist/migrate.js.map +0 -1
  130. package/dist/migrateDown.d.ts +0 -3
  131. package/dist/migrateDown.d.ts.map +0 -1
  132. package/dist/migrateDown.js +0 -63
  133. package/dist/migrateDown.js.map +0 -1
  134. package/dist/migrateFresh.d.ts +0 -8
  135. package/dist/migrateFresh.d.ts.map +0 -1
  136. package/dist/migrateFresh.js +0 -72
  137. package/dist/migrateFresh.js.map +0 -1
  138. package/dist/migrateRefresh.d.ts +0 -6
  139. package/dist/migrateRefresh.d.ts.map +0 -1
  140. package/dist/migrateRefresh.js +0 -102
  141. package/dist/migrateRefresh.js.map +0 -1
  142. package/dist/migrateReset.d.ts +0 -6
  143. package/dist/migrateReset.d.ts.map +0 -1
  144. package/dist/migrateReset.js +0 -82
  145. package/dist/migrateReset.js.map +0 -1
  146. package/dist/migrateStatus.d.ts +0 -3
  147. package/dist/migrateStatus.d.ts.map +0 -1
  148. package/dist/migrateStatus.js +0 -44
  149. package/dist/migrateStatus.js.map +0 -1
  150. package/dist/queries/buildAndOrConditions.d.ts +0 -17
  151. package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
  152. package/dist/queries/buildAndOrConditions.js +0 -29
  153. package/dist/queries/buildAndOrConditions.js.map +0 -1
  154. package/dist/queries/buildQuery.d.ts +0 -31
  155. package/dist/queries/buildQuery.d.ts.map +0 -1
  156. package/dist/queries/buildQuery.js +0 -76
  157. package/dist/queries/buildQuery.js.map +0 -1
  158. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
  159. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  160. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +0 -14
  161. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  162. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
  163. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  164. package/dist/queries/createJSONQuery/formatJSONPathSegment.js +0 -5
  165. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  166. package/dist/queries/createJSONQuery/index.d.ts +0 -10
  167. package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
  168. package/dist/queries/createJSONQuery/index.js +0 -54
  169. package/dist/queries/createJSONQuery/index.js.map +0 -1
  170. package/dist/queries/getTableColumnFromPath.d.ts +0 -51
  171. package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
  172. package/dist/queries/getTableColumnFromPath.js +0 -412
  173. package/dist/queries/getTableColumnFromPath.js.map +0 -1
  174. package/dist/queries/operatorMap.d.ts +0 -18
  175. package/dist/queries/operatorMap.d.ts.map +0 -1
  176. package/dist/queries/operatorMap.js +0 -24
  177. package/dist/queries/operatorMap.js.map +0 -1
  178. package/dist/queries/parseParams.d.ts +0 -17
  179. package/dist/queries/parseParams.d.ts.map +0 -1
  180. package/dist/queries/parseParams.js +0 -182
  181. package/dist/queries/parseParams.js.map +0 -1
  182. package/dist/queries/sanitizeQueryValue.d.ts +0 -15
  183. package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
  184. package/dist/queries/sanitizeQueryValue.js +0 -90
  185. package/dist/queries/sanitizeQueryValue.js.map +0 -1
  186. package/dist/queries/selectDistinct.d.ts +0 -23
  187. package/dist/queries/selectDistinct.d.ts.map +0 -1
  188. package/dist/queries/selectDistinct.js +0 -41
  189. package/dist/queries/selectDistinct.js.map +0 -1
  190. package/dist/queryDrafts.d.ts +0 -3
  191. package/dist/queryDrafts.d.ts.map +0 -1
  192. package/dist/queryDrafts.js +0 -45
  193. package/dist/queryDrafts.js.map +0 -1
  194. package/dist/schema/build.d.ts +0 -29
  195. package/dist/schema/build.d.ts.map +0 -1
  196. package/dist/schema/build.js +0 -285
  197. package/dist/schema/build.js.map +0 -1
  198. package/dist/schema/createIndex.d.ts +0 -12
  199. package/dist/schema/createIndex.d.ts.map +0 -1
  200. package/dist/schema/createIndex.js +0 -18
  201. package/dist/schema/createIndex.js.map +0 -1
  202. package/dist/schema/getTableName.d.ts +0 -32
  203. package/dist/schema/getTableName.d.ts.map +0 -1
  204. package/dist/schema/getTableName.js +0 -31
  205. package/dist/schema/getTableName.js.map +0 -1
  206. package/dist/schema/idToUUID.d.ts +0 -3
  207. package/dist/schema/idToUUID.d.ts.map +0 -1
  208. package/dist/schema/idToUUID.js +0 -11
  209. package/dist/schema/idToUUID.js.map +0 -1
  210. package/dist/schema/parentIDColumnMap.d.ts +0 -4
  211. package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
  212. package/dist/schema/parentIDColumnMap.js +0 -9
  213. package/dist/schema/parentIDColumnMap.js.map +0 -1
  214. package/dist/schema/setColumnID.d.ts +0 -11
  215. package/dist/schema/setColumnID.d.ts.map +0 -1
  216. package/dist/schema/setColumnID.js +0 -24
  217. package/dist/schema/setColumnID.js.map +0 -1
  218. package/dist/schema/traverseFields.d.ts +0 -38
  219. package/dist/schema/traverseFields.d.ts.map +0 -1
  220. package/dist/schema/traverseFields.js +0 -530
  221. package/dist/schema/traverseFields.js.map +0 -1
  222. package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -11
  223. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
  224. package/dist/schema/validateExistingBlockIsIdentical.js +0 -70
  225. package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
  226. package/dist/transactions/beginTransaction.d.ts +0 -3
  227. package/dist/transactions/beginTransaction.d.ts.map +0 -1
  228. package/dist/transactions/beginTransaction.js +0 -47
  229. package/dist/transactions/beginTransaction.js.map +0 -1
  230. package/dist/transactions/commitTransaction.d.ts +0 -3
  231. package/dist/transactions/commitTransaction.d.ts.map +0 -1
  232. package/dist/transactions/commitTransaction.js +0 -14
  233. package/dist/transactions/commitTransaction.js.map +0 -1
  234. package/dist/transactions/rollbackTransaction.d.ts +0 -3
  235. package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
  236. package/dist/transactions/rollbackTransaction.js +0 -13
  237. package/dist/transactions/rollbackTransaction.js.map +0 -1
  238. package/dist/transform/read/hasManyNumber.d.ts +0 -10
  239. package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
  240. package/dist/transform/read/hasManyNumber.js +0 -10
  241. package/dist/transform/read/hasManyNumber.js.map +0 -1
  242. package/dist/transform/read/hasManyText.d.ts +0 -10
  243. package/dist/transform/read/hasManyText.d.ts.map +0 -1
  244. package/dist/transform/read/hasManyText.js +0 -10
  245. package/dist/transform/read/hasManyText.js.map +0 -1
  246. package/dist/transform/read/index.d.ts +0 -12
  247. package/dist/transform/read/index.d.ts.map +0 -1
  248. package/dist/transform/read/index.js +0 -43
  249. package/dist/transform/read/index.js.map +0 -1
  250. package/dist/transform/read/relationship.d.ts +0 -10
  251. package/dist/transform/read/relationship.d.ts.map +0 -1
  252. package/dist/transform/read/relationship.js +0 -64
  253. package/dist/transform/read/relationship.js.map +0 -1
  254. package/dist/transform/read/traverseFields.d.ts +0 -52
  255. package/dist/transform/read/traverseFields.d.ts.map +0 -1
  256. package/dist/transform/read/traverseFields.js +0 -421
  257. package/dist/transform/read/traverseFields.js.map +0 -1
  258. package/dist/transform/write/array.d.ts +0 -26
  259. package/dist/transform/write/array.d.ts.map +0 -1
  260. package/dist/transform/write/array.js +0 -58
  261. package/dist/transform/write/array.js.map +0 -1
  262. package/dist/transform/write/blocks.d.ts +0 -25
  263. package/dist/transform/write/blocks.d.ts.map +0 -1
  264. package/dist/transform/write/blocks.js +0 -54
  265. package/dist/transform/write/blocks.js.map +0 -1
  266. package/dist/transform/write/index.d.ts +0 -13
  267. package/dist/transform/write/index.d.ts.map +0 -1
  268. package/dist/transform/write/index.js +0 -41
  269. package/dist/transform/write/index.js.map +0 -1
  270. package/dist/transform/write/numbers.d.ts +0 -8
  271. package/dist/transform/write/numbers.d.ts.map +0 -1
  272. package/dist/transform/write/numbers.js +0 -11
  273. package/dist/transform/write/numbers.js.map +0 -1
  274. package/dist/transform/write/relationships.d.ts +0 -10
  275. package/dist/transform/write/relationships.d.ts.map +0 -1
  276. package/dist/transform/write/relationships.js +0 -23
  277. package/dist/transform/write/relationships.js.map +0 -1
  278. package/dist/transform/write/selects.d.ts +0 -8
  279. package/dist/transform/write/selects.d.ts.map +0 -1
  280. package/dist/transform/write/selects.js +0 -20
  281. package/dist/transform/write/selects.js.map +0 -1
  282. package/dist/transform/write/texts.d.ts +0 -8
  283. package/dist/transform/write/texts.d.ts.map +0 -1
  284. package/dist/transform/write/texts.js +0 -11
  285. package/dist/transform/write/texts.js.map +0 -1
  286. package/dist/transform/write/traverseFields.d.ts +0 -50
  287. package/dist/transform/write/traverseFields.d.ts.map +0 -1
  288. package/dist/transform/write/traverseFields.js +0 -428
  289. package/dist/transform/write/traverseFields.js.map +0 -1
  290. package/dist/transform/write/types.d.ts +0 -43
  291. package/dist/transform/write/types.d.ts.map +0 -1
  292. package/dist/transform/write/types.js +0 -3
  293. package/dist/transform/write/types.js.map +0 -1
  294. package/dist/update.d.ts +0 -3
  295. package/dist/update.d.ts.map +0 -1
  296. package/dist/update.js +0 -58
  297. package/dist/update.js.map +0 -1
  298. package/dist/updateGlobal.d.ts +0 -5
  299. package/dist/updateGlobal.d.ts.map +0 -1
  300. package/dist/updateGlobal.js +0 -28
  301. package/dist/updateGlobal.js.map +0 -1
  302. package/dist/updateGlobalVersion.d.ts +0 -5
  303. package/dist/updateGlobalVersion.d.ts.map +0 -1
  304. package/dist/updateGlobalVersion.js +0 -40
  305. package/dist/updateGlobalVersion.js.map +0 -1
  306. package/dist/updateVersion.d.ts +0 -5
  307. package/dist/updateVersion.d.ts.map +0 -1
  308. package/dist/updateVersion.js +0 -40
  309. package/dist/updateVersion.js.map +0 -1
  310. package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
  311. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
  312. package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
  313. package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
  314. package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
  315. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
  316. package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
  317. package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
  318. package/dist/upsertRow/index.d.ts +0 -4
  319. package/dist/upsertRow/index.d.ts.map +0 -1
  320. package/dist/upsertRow/index.js +0 -276
  321. package/dist/upsertRow/index.js.map +0 -1
  322. package/dist/upsertRow/insertArrays.d.ts +0 -13
  323. package/dist/upsertRow/insertArrays.d.ts.map +0 -1
  324. package/dist/upsertRow/insertArrays.js +0 -68
  325. package/dist/upsertRow/insertArrays.js.map +0 -1
  326. package/dist/upsertRow/types.d.ts +0 -27
  327. package/dist/upsertRow/types.d.ts.map +0 -1
  328. package/dist/upsertRow/types.js +0 -3
  329. package/dist/upsertRow/types.js.map +0 -1
  330. package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
  331. package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
  332. package/dist/utilities/appendPrefixToKeys.js +0 -6
  333. package/dist/utilities/appendPrefixToKeys.js.map +0 -1
  334. package/dist/utilities/createBlocksMap.d.ts +0 -5
  335. package/dist/utilities/createBlocksMap.d.ts.map +0 -1
  336. package/dist/utilities/createBlocksMap.js +0 -29
  337. package/dist/utilities/createBlocksMap.js.map +0 -1
  338. package/dist/utilities/createMigrationTable.d.ts +0 -3
  339. package/dist/utilities/createMigrationTable.d.ts.map +0 -1
  340. package/dist/utilities/createMigrationTable.js +0 -13
  341. package/dist/utilities/createMigrationTable.js.map +0 -1
  342. package/dist/utilities/createRelationshipMap.d.ts +0 -2
  343. package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
  344. package/dist/utilities/createRelationshipMap.js +0 -19
  345. package/dist/utilities/createRelationshipMap.js.map +0 -1
  346. package/dist/utilities/hasLocalesTable.d.ts +0 -3
  347. package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
  348. package/dist/utilities/hasLocalesTable.js +0 -11
  349. package/dist/utilities/hasLocalesTable.js.map +0 -1
  350. package/dist/utilities/isArrayOfRows.d.ts +0 -2
  351. package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
  352. package/dist/utilities/isArrayOfRows.js +0 -5
  353. package/dist/utilities/isArrayOfRows.js.map +0 -1
  354. package/dist/utilities/migrationTableExists.d.ts +0 -3
  355. package/dist/utilities/migrationTableExists.d.ts.map +0 -1
  356. package/dist/utilities/migrationTableExists.js +0 -9
  357. package/dist/utilities/migrationTableExists.js.map +0 -1
  358. package/dist/utilities/parseError.d.ts +0 -5
  359. package/dist/utilities/parseError.d.ts.map +0 -1
  360. package/dist/utilities/parseError.js +0 -17
  361. package/dist/utilities/parseError.js.map +0 -1
  362. package/dist/utilities/pushDevSchema.d.ts +0 -9
  363. package/dist/utilities/pushDevSchema.d.ts.map +0 -1
  364. package/dist/utilities/pushDevSchema.js +0 -58
  365. package/dist/utilities/pushDevSchema.js.map +0 -1
  366. package/src/index.ts +0 -156
@@ -1,163 +0,0 @@
1
- import { inArray, sql } from 'drizzle-orm';
2
- import buildQuery from '../queries/buildQuery.js';
3
- import { selectDistinct } from '../queries/selectDistinct.js';
4
- import { transform } from '../transform/read/index.js';
5
- import { buildFindManyArgs } from './buildFindManyArgs.js';
6
- import { chainMethods } from './chainMethods.js';
7
- export const findMany = async function find({ adapter, fields, limit: limitArg, locale, page = 1, pagination, req = {}, skip, sort, tableName, where: whereArg }) {
8
- const db = adapter.sessions[req.transactionID]?.db || adapter.drizzle;
9
- const table = adapter.tables[tableName];
10
- const limit = limitArg ?? 10;
11
- let totalDocs;
12
- let totalPages;
13
- let hasPrevPage;
14
- let hasNextPage;
15
- let pagingCounter;
16
- const { joinAliases, joins, orderBy, selectFields, where } = await buildQuery({
17
- adapter,
18
- fields,
19
- locale,
20
- sort,
21
- tableName,
22
- where: whereArg
23
- });
24
- const orderedIDMap = {};
25
- let orderedIDs;
26
- const selectDistinctMethods = [];
27
- if (orderBy?.order && orderBy?.column) {
28
- selectDistinctMethods.push({
29
- args: [
30
- orderBy.order(orderBy.column)
31
- ],
32
- method: 'orderBy'
33
- });
34
- }
35
- const findManyArgs = buildFindManyArgs({
36
- adapter,
37
- depth: 0,
38
- fields,
39
- tableName
40
- });
41
- selectDistinctMethods.push({
42
- args: [
43
- skip || (page - 1) * limit
44
- ],
45
- method: 'offset'
46
- });
47
- selectDistinctMethods.push({
48
- args: [
49
- limit === 0 ? undefined : limit
50
- ],
51
- method: 'limit'
52
- });
53
- const selectDistinctResult = await selectDistinct({
54
- adapter,
55
- chainedMethods: selectDistinctMethods,
56
- db,
57
- joinAliases,
58
- joins,
59
- selectFields,
60
- tableName,
61
- where
62
- });
63
- if (selectDistinctResult) {
64
- if (selectDistinctResult.length === 0) {
65
- return {
66
- docs: [],
67
- hasNextPage: false,
68
- hasPrevPage: false,
69
- limit,
70
- nextPage: null,
71
- page: 1,
72
- pagingCounter: 0,
73
- prevPage: null,
74
- totalDocs: 0,
75
- totalPages: 0
76
- };
77
- } else {
78
- // set the id in an object for sorting later
79
- selectDistinctResult.forEach(({ id }, i)=>{
80
- orderedIDMap[id] = i;
81
- });
82
- orderedIDs = Object.keys(orderedIDMap);
83
- findManyArgs.where = inArray(adapter.tables[tableName].id, orderedIDs);
84
- }
85
- } else {
86
- findManyArgs.limit = limitArg === 0 ? undefined : limitArg;
87
- const offset = skip || (page - 1) * limitArg;
88
- if (!Number.isNaN(offset)) findManyArgs.offset = offset;
89
- if (where) {
90
- findManyArgs.where = where;
91
- }
92
- findManyArgs.orderBy = orderBy.order(orderBy.column);
93
- }
94
- const findPromise = db.query[tableName].findMany(findManyArgs);
95
- if (pagination !== false && (orderedIDs ? orderedIDs?.length <= limit : true)) {
96
- const selectCountMethods = [];
97
- joinAliases.forEach(({ condition, table })=>{
98
- selectCountMethods.push({
99
- args: [
100
- table,
101
- condition
102
- ],
103
- method: 'leftJoin'
104
- });
105
- });
106
- Object.entries(joins).forEach(([joinTable, condition])=>{
107
- if (joinTable) {
108
- selectCountMethods.push({
109
- args: [
110
- adapter.tables[joinTable],
111
- condition
112
- ],
113
- method: 'leftJoin'
114
- });
115
- }
116
- });
117
- const countResult = await chainMethods({
118
- methods: selectCountMethods,
119
- query: db.select({
120
- count: sql`count
121
- (DISTINCT ${adapter.tables[tableName].id})`
122
- }).from(table).where(where)
123
- });
124
- totalDocs = Number(countResult[0].count);
125
- totalPages = typeof limit === 'number' && limit !== 0 ? Math.ceil(totalDocs / limit) : 1;
126
- hasPrevPage = page > 1;
127
- hasNextPage = totalPages > page;
128
- pagingCounter = (page - 1) * limit + 1;
129
- }
130
- const rawDocs = await findPromise;
131
- // sort rawDocs from selectQuery
132
- if (Object.keys(orderedIDMap).length > 0) {
133
- rawDocs.sort((a, b)=>orderedIDMap[a.id] - orderedIDMap[b.id]);
134
- }
135
- if (pagination === false || !totalDocs) {
136
- totalDocs = rawDocs.length;
137
- totalPages = 1;
138
- pagingCounter = 1;
139
- hasPrevPage = false;
140
- hasNextPage = false;
141
- }
142
- const docs = rawDocs.map((data)=>{
143
- return transform({
144
- config: adapter.payload.config,
145
- data,
146
- fields
147
- });
148
- });
149
- return {
150
- docs,
151
- hasNextPage,
152
- hasPrevPage,
153
- limit,
154
- nextPage: hasNextPage ? page + 1 : null,
155
- page,
156
- pagingCounter,
157
- prevPage: hasPrevPage ? page - 1 : null,
158
- totalDocs,
159
- totalPages
160
- };
161
- };
162
-
163
- //# sourceMappingURL=findMany.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/find/findMany.ts"],"sourcesContent":["import type { FindArgs } from 'payload/database'\nimport type { Field, PayloadRequest, TypeWithID } from 'payload/types'\n\nimport { inArray, sql } from 'drizzle-orm'\n\nimport type { PostgresAdapter } from '../types.js'\nimport type { ChainedMethods } from './chainMethods.js'\n\nimport buildQuery from '../queries/buildQuery.js'\nimport { selectDistinct } from '../queries/selectDistinct.js'\nimport { transform } from '../transform/read/index.js'\nimport { buildFindManyArgs } from './buildFindManyArgs.js'\nimport { chainMethods } from './chainMethods.js'\n\ntype Args = Omit<FindArgs, 'collection'> & {\n adapter: PostgresAdapter\n fields: Field[]\n tableName: string\n}\n\nexport const findMany = async function find({\n adapter,\n fields,\n limit: limitArg,\n locale,\n page = 1,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort,\n tableName,\n where: whereArg,\n}: Args) {\n const db = adapter.sessions[req.transactionID]?.db || adapter.drizzle\n const table = adapter.tables[tableName]\n\n const limit = limitArg ?? 10\n let totalDocs: number\n let totalPages: number\n let hasPrevPage: boolean\n let hasNextPage: boolean\n let pagingCounter: number\n\n const { joinAliases, joins, orderBy, selectFields, where } = await buildQuery({\n adapter,\n fields,\n locale,\n sort,\n tableName,\n where: whereArg,\n })\n\n const orderedIDMap: Record<number | string, number> = {}\n let orderedIDs: (number | string)[]\n\n const selectDistinctMethods: ChainedMethods = []\n\n if (orderBy?.order && orderBy?.column) {\n selectDistinctMethods.push({\n args: [orderBy.order(orderBy.column)],\n method: 'orderBy',\n })\n }\n\n const findManyArgs = buildFindManyArgs({\n adapter,\n depth: 0,\n fields,\n tableName,\n })\n\n selectDistinctMethods.push({ args: [skip || (page - 1) * limit], method: 'offset' })\n selectDistinctMethods.push({ args: [limit === 0 ? undefined : limit], method: 'limit' })\n\n const selectDistinctResult = await selectDistinct({\n adapter,\n chainedMethods: selectDistinctMethods,\n db,\n joinAliases,\n joins,\n selectFields,\n tableName,\n where,\n })\n\n if (selectDistinctResult) {\n if (selectDistinctResult.length === 0) {\n return {\n docs: [],\n hasNextPage: false,\n hasPrevPage: false,\n limit,\n nextPage: null,\n page: 1,\n pagingCounter: 0,\n prevPage: null,\n totalDocs: 0,\n totalPages: 0,\n }\n } else {\n // set the id in an object for sorting later\n selectDistinctResult.forEach(({ id }, i) => {\n orderedIDMap[id] = i\n })\n orderedIDs = Object.keys(orderedIDMap)\n findManyArgs.where = inArray(adapter.tables[tableName].id, orderedIDs)\n }\n } else {\n findManyArgs.limit = limitArg === 0 ? undefined : limitArg\n\n const offset = skip || (page - 1) * limitArg\n\n if (!Number.isNaN(offset)) findManyArgs.offset = offset\n\n if (where) {\n findManyArgs.where = where\n }\n findManyArgs.orderBy = orderBy.order(orderBy.column)\n }\n\n const findPromise = db.query[tableName].findMany(findManyArgs)\n\n if (pagination !== false && (orderedIDs ? orderedIDs?.length <= limit : true)) {\n const selectCountMethods: ChainedMethods = []\n\n joinAliases.forEach(({ condition, table }) => {\n selectCountMethods.push({\n args: [table, condition],\n method: 'leftJoin',\n })\n })\n\n Object.entries(joins).forEach(([joinTable, condition]) => {\n if (joinTable) {\n selectCountMethods.push({\n args: [adapter.tables[joinTable], condition],\n method: 'leftJoin',\n })\n }\n })\n\n const countResult = await chainMethods({\n methods: selectCountMethods,\n query: db\n .select({\n count: sql<number>`count\n (DISTINCT ${adapter.tables[tableName].id})`,\n })\n .from(table)\n .where(where),\n })\n totalDocs = Number(countResult[0].count)\n totalPages = typeof limit === 'number' && limit !== 0 ? Math.ceil(totalDocs / limit) : 1\n hasPrevPage = page > 1\n hasNextPage = totalPages > page\n pagingCounter = (page - 1) * limit + 1\n }\n\n const rawDocs = await findPromise\n // sort rawDocs from selectQuery\n if (Object.keys(orderedIDMap).length > 0) {\n rawDocs.sort((a, b) => orderedIDMap[a.id] - orderedIDMap[b.id])\n }\n\n if (pagination === false || !totalDocs) {\n totalDocs = rawDocs.length\n totalPages = 1\n pagingCounter = 1\n hasPrevPage = false\n hasNextPage = false\n }\n\n const docs = rawDocs.map((data: TypeWithID) => {\n return transform({\n config: adapter.payload.config,\n data,\n fields,\n })\n })\n\n return {\n docs,\n hasNextPage,\n hasPrevPage,\n limit,\n nextPage: hasNextPage ? page + 1 : null,\n page,\n pagingCounter,\n prevPage: hasPrevPage ? page - 1 : null,\n totalDocs,\n totalPages,\n }\n}\n"],"names":["inArray","sql","buildQuery","selectDistinct","transform","buildFindManyArgs","chainMethods","findMany","find","adapter","fields","limit","limitArg","locale","page","pagination","req","skip","sort","tableName","where","whereArg","db","sessions","transactionID","drizzle","table","tables","totalDocs","totalPages","hasPrevPage","hasNextPage","pagingCounter","joinAliases","joins","orderBy","selectFields","orderedIDMap","orderedIDs","selectDistinctMethods","order","column","push","args","method","findManyArgs","depth","undefined","selectDistinctResult","chainedMethods","length","docs","nextPage","prevPage","forEach","id","i","Object","keys","offset","Number","isNaN","findPromise","query","selectCountMethods","condition","entries","joinTable","countResult","methods","select","count","from","Math","ceil","rawDocs","a","b","map","data","config","payload"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,OAAO,EAAEC,GAAG,QAAQ,cAAa;AAK1C,OAAOC,gBAAgB,2BAA0B;AACjD,SAASC,cAAc,QAAQ,+BAA8B;AAC7D,SAASC,SAAS,QAAQ,6BAA4B;AACtD,SAASC,iBAAiB,QAAQ,yBAAwB;AAC1D,SAASC,YA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,OAAO,IAAI;QACnCc;QACAC;IACF;AACF,EAAC"}
@@ -1,16 +0,0 @@
1
- import type { Field } from 'payload/types';
2
- import type { PostgresAdapter } from '../types.js';
3
- type TraverseFieldArgs = {
4
- _locales: Record<string, unknown>;
5
- adapter: PostgresAdapter;
6
- currentArgs: Record<string, unknown>;
7
- currentTableName: string;
8
- depth?: number;
9
- fields: Field[];
10
- path: string;
11
- topLevelArgs: Record<string, unknown>;
12
- topLevelTableName: string;
13
- };
14
- export declare const traverseFields: ({ _locales, adapter, currentArgs, currentTableName, depth, fields, path, topLevelArgs, topLevelTableName, }: TraverseFieldArgs) => Record<string, unknown>;
15
- export {};
16
- //# sourceMappingURL=traverseFields.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"traverseFields.d.ts","sourceRoot":"","sources":["../../src/find/traverseFields.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAI1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAKlD,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACjC,OAAO,EAAE,eAAe,CAAA;IACxB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACpC,gBAAgB,EAAE,MAAM,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,KAAK,EAAE,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACrC,iBAAiB,EAAE,MAAM,CAAA;CAC1B,CAAA;AAED,eAAO,MAAM,cAAc,gHAUxB,iBAAiB,4BAmKnB,CAAA"}
@@ -1,154 +0,0 @@
1
- /* eslint-disable no-param-reassign */ import { fieldAffectsData, tabHasName } from 'payload/types';
2
- import { getTableName } from '../schema/getTableName.js';
3
- export const traverseFields = ({ _locales, adapter, currentArgs, currentTableName, depth, fields, path, topLevelArgs, topLevelTableName })=>{
4
- fields.forEach((field)=>{
5
- if (field.type === 'collapsible' || field.type === 'row') {
6
- traverseFields({
7
- _locales,
8
- adapter,
9
- currentArgs,
10
- currentTableName,
11
- depth,
12
- fields: field.fields,
13
- path,
14
- topLevelArgs,
15
- topLevelTableName
16
- });
17
- return;
18
- }
19
- if (field.type === 'tabs') {
20
- field.tabs.forEach((tab)=>{
21
- const tabPath = tabHasName(tab) ? `${path}${tab.name}_` : path;
22
- traverseFields({
23
- _locales,
24
- adapter,
25
- currentArgs,
26
- currentTableName,
27
- depth,
28
- fields: tab.fields,
29
- path: tabPath,
30
- topLevelArgs,
31
- topLevelTableName
32
- });
33
- });
34
- return;
35
- }
36
- if (fieldAffectsData(field)) {
37
- switch(field.type){
38
- case 'array':
39
- {
40
- const withArray = {
41
- columns: {
42
- _parentID: false
43
- },
44
- orderBy: ({ _order }, { asc })=>[
45
- asc(_order)
46
- ],
47
- with: {}
48
- };
49
- const arrayTableName = getTableName({
50
- adapter,
51
- config: field,
52
- parentTableName: currentTableName,
53
- prefix: `${currentTableName}_${path}`
54
- });
55
- const arrayTableNameWithLocales = getTableName({
56
- adapter,
57
- config: field,
58
- locales: true,
59
- parentTableName: currentTableName,
60
- prefix: `${currentTableName}_${path}`
61
- });
62
- if (adapter.tables[arrayTableNameWithLocales]) withArray.with._locales = _locales;
63
- currentArgs.with[`${path}${field.name}`] = withArray;
64
- traverseFields({
65
- _locales,
66
- adapter,
67
- currentArgs: withArray,
68
- currentTableName: arrayTableName,
69
- depth,
70
- fields: field.fields,
71
- path: '',
72
- topLevelArgs,
73
- topLevelTableName
74
- });
75
- break;
76
- }
77
- case 'select':
78
- {
79
- if (field.hasMany) {
80
- const withSelect = {
81
- columns: {
82
- id: false,
83
- order: false,
84
- parent: false
85
- },
86
- orderBy: ({ order }, { asc })=>[
87
- asc(order)
88
- ]
89
- };
90
- currentArgs.with[`${path}${field.name}`] = withSelect;
91
- }
92
- break;
93
- }
94
- case 'blocks':
95
- field.blocks.forEach((block)=>{
96
- const blockKey = `_blocks_${block.slug}`;
97
- if (!topLevelArgs[blockKey]) {
98
- const withBlock = {
99
- columns: {
100
- _parentID: false
101
- },
102
- orderBy: ({ _order }, { asc })=>[
103
- asc(_order)
104
- ],
105
- with: {}
106
- };
107
- const tableName = getTableName({
108
- adapter,
109
- config: block,
110
- parentTableName: topLevelTableName,
111
- prefix: `${topLevelTableName}_blocks_`
112
- });
113
- if (adapter.tables[`${tableName}${adapter.localesSuffix}`]) {
114
- withBlock.with._locales = _locales;
115
- }
116
- topLevelArgs.with[blockKey] = withBlock;
117
- traverseFields({
118
- _locales,
119
- adapter,
120
- currentArgs: withBlock,
121
- currentTableName: tableName,
122
- depth,
123
- fields: block.fields,
124
- path: '',
125
- topLevelArgs,
126
- topLevelTableName
127
- });
128
- }
129
- });
130
- break;
131
- case 'group':
132
- traverseFields({
133
- _locales,
134
- adapter,
135
- currentArgs,
136
- currentTableName,
137
- depth,
138
- fields: field.fields,
139
- path: `${path}${field.name}_`,
140
- topLevelArgs,
141
- topLevelTableName
142
- });
143
- break;
144
- default:
145
- {
146
- break;
147
- }
148
- }
149
- }
150
- });
151
- return topLevelArgs;
152
- };
153
-
154
- //# sourceMappingURL=traverseFields.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/find/traverseFields.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { Field } from 'payload/types'\n\nimport { fieldAffectsData, tabHasName } from 'payload/types'\n\nimport type { PostgresAdapter } from '../types.js'\nimport type { Result } from './buildFindManyArgs.js'\n\nimport { getTableName } from '../schema/getTableName.js'\n\ntype TraverseFieldArgs = {\n _locales: Record<string, unknown>\n adapter: PostgresAdapter\n currentArgs: Record<string, unknown>\n currentTableName: string\n depth?: number\n fields: Field[]\n path: string\n topLevelArgs: Record<string, unknown>\n topLevelTableName: string\n}\n\nexport const traverseFields = ({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields,\n path,\n topLevelArgs,\n topLevelTableName,\n}: TraverseFieldArgs) => {\n fields.forEach((field) => {\n if (field.type === 'collapsible' || field.type === 'row') {\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: field.fields,\n path,\n topLevelArgs,\n topLevelTableName,\n })\n\n return\n }\n\n if (field.type === 'tabs') {\n field.tabs.forEach((tab) => {\n const tabPath = tabHasName(tab) ? `${path}${tab.name}_` : path\n\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: tab.fields,\n path: tabPath,\n topLevelArgs,\n topLevelTableName,\n })\n })\n\n return\n }\n\n if (fieldAffectsData(field)) {\n switch (field.type) {\n case 'array': {\n const withArray: Result = {\n columns: {\n _parentID: false,\n },\n orderBy: ({ _order }, { asc }) => [asc(_order)],\n with: {},\n }\n\n const arrayTableName = getTableName({\n adapter,\n config: field,\n parentTableName: currentTableName,\n prefix: `${currentTableName}_${path}`,\n })\n\n const arrayTableNameWithLocales = getTableName({\n adapter,\n config: field,\n locales: true,\n parentTableName: currentTableName,\n prefix: `${currentTableName}_${path}`,\n })\n\n if (adapter.tables[arrayTableNameWithLocales]) withArray.with._locales = _locales\n currentArgs.with[`${path}${field.name}`] = withArray\n\n traverseFields({\n _locales,\n adapter,\n currentArgs: withArray,\n currentTableName: arrayTableName,\n depth,\n fields: field.fields,\n path: '',\n topLevelArgs,\n topLevelTableName,\n })\n\n break\n }\n\n case 'select': {\n if (field.hasMany) {\n const withSelect: Result = {\n columns: {\n id: false,\n order: false,\n parent: false,\n },\n orderBy: ({ order }, { asc }) => [asc(order)],\n }\n\n currentArgs.with[`${path}${field.name}`] = withSelect\n }\n\n break\n }\n\n case 'blocks':\n field.blocks.forEach((block) => {\n const blockKey = `_blocks_${block.slug}`\n\n if (!topLevelArgs[blockKey]) {\n const withBlock: Result = {\n columns: {\n _parentID: false,\n },\n orderBy: ({ _order }, { asc }) => [asc(_order)],\n with: {},\n }\n\n const tableName = getTableName({\n adapter,\n config: block,\n parentTableName: topLevelTableName,\n prefix: `${topLevelTableName}_blocks_`,\n })\n\n if (adapter.tables[`${tableName}${adapter.localesSuffix}`]) {\n withBlock.with._locales = _locales\n }\n topLevelArgs.with[blockKey] = withBlock\n\n traverseFields({\n _locales,\n adapter,\n currentArgs: withBlock,\n currentTableName: tableName,\n depth,\n fields: block.fields,\n path: '',\n topLevelArgs,\n topLevelTableName,\n })\n }\n })\n\n break\n\n case 'group':\n traverseFields({\n _locales,\n adapter,\n currentArgs,\n currentTableName,\n depth,\n fields: field.fields,\n path: `${path}${field.name}_`,\n topLevelArgs,\n topLevelTableName,\n })\n\n break\n\n default: {\n break\n }\n }\n }\n })\n\n return topLevelArgs\n}\n"],"names":["fieldAffectsData","tabHasName","getTableName","traverseFields","_locales","adapter","currentArgs","currentTableName","depth","fields","path","topLevelArgs","topLevelTableName","forEach","field","type","tabs","tab","tabPath","name","withArray","columns","_parentID","orderBy","_order","asc","with","arrayTableName","config","parentTableName","prefix","arrayTableNameWithLocales","locales","tables","hasMany","withSelect","id","order","parent","blocks","block","blockKey","slug","withBlock","tableName","localesSuffix"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAAA,oCAAoC,GAGpC,SAASA,gBAAgB,EAAEC,UAAU,QAAQ,gBAAe;AAK5D,SAASC,YAAY,QAAQ,4BAA2B;AAcxD,OAAO,MAAMC,iBAAiB,CAAC,EAC7BC,QAAQ,EACRC,OAAO,EACPC,WAAW,EACXC,gBAAgB,EAChBC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,YAAY,EACZC,iBAAiB,EACC;IAClBH,OAAOI,OAAO,CAAC,CAACC;QACd,IAAIA,M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ACbpC,kBAAkBqC;gCAClBpC;gCACAC,QAAQ+B,MAAM/B,MAAM;gCACpBC,MAAM;gCACNC;gCACAC;4BACF;wBACF;oBACF;oBAEA;gBAEF,KAAK;oBACHT,eAAe;wBACbC;wBACAC;wBACAC;wBACAC;wBACAC;wBACAC,QAAQK,MAAML,MAAM;wBACpBC,MAAM,CAAC,EAAEA,KAAK,EAAEI,MAAMK,IAAI,CAAC,CAAC,CAAC;wBAC7BR;wBACAC;oBACF;oBAEA;gBAEF;oBAAS;wBACP;oBACF;YACF;QACF;IACF;IAEA,OAAOD;AACT,EAAC"}
package/dist/find.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Find } from 'payload/database';
2
- export declare const find: Find;
3
- //# sourceMappingURL=find.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../src/find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAQ5C,eAAO,MAAM,IAAI,EAAE,IAgClB,CAAA"}
package/dist/find.js DELETED
@@ -1,24 +0,0 @@
1
- import { findMany } from './find/findMany.js';
2
- import { getTableName } from './schema/getTableName.js';
3
- export const find = async function find({ collection, limit, locale, page = 1, pagination, req = {}, sort: sortArg, where }) {
4
- const collectionConfig = this.payload.collections[collection].config;
5
- const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort;
6
- const tableName = getTableName({
7
- adapter: this,
8
- config: collectionConfig
9
- });
10
- return findMany({
11
- adapter: this,
12
- fields: collectionConfig.fields,
13
- limit,
14
- locale,
15
- page,
16
- pagination,
17
- req,
18
- sort,
19
- tableName,
20
- where
21
- });
22
- };
23
-
24
- //# sourceMappingURL=find.js.map
package/dist/find.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/find.ts"],"sourcesContent":["import type { Find } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const find: Find = async function find(\n this: PostgresAdapter,\n {\n collection,\n limit,\n locale,\n page = 1,\n pagination,\n req = {} as PayloadRequest,\n sort: sortArg,\n where,\n },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort\n const tableName = getTableName({\n adapter: this,\n config: collectionConfig,\n })\n\n return findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit,\n locale,\n page,\n pagination,\n req,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["findMany","getTableName","find","collection","limit","locale","page","pagination","req","sort","sortArg","where","collectionConfig","payload","collections","config","defaultSort","tableName","adapter","fields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,OAAa,eAAeA,KAEvC,EACEC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,OAAO,CAAC,EACRC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACX,WAAW,CAACY,MAAM;IAC/F,MAAMN,OAAO,OAAOC,YAAY,WAAWA,UAAUE,iBAAiBI,WAAW;IACjF,MAAMC,YAAYhB,aAAa;QAC7BiB,SAAS,IAAI;QACbH,QAAQH;IACV;IAEA,OAAOZ,SAAS;QACdkB,SAAS,IAAI;QACbC,QAAQP,iBAAiBO,MAAM;QAC/Bf;QACAC;QACAC;QACAC;QACAC;QACAC;QACAQ;QACAN;IACF;AACF,EAAC"}
@@ -1,3 +0,0 @@
1
- import type { FindGlobal } from 'payload/database';
2
- export declare const findGlobal: FindGlobal;
3
- //# sourceMappingURL=findGlobal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findGlobal.d.ts","sourceRoot":"","sources":["../src/findGlobal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAOlD,eAAO,MAAM,UAAU,EAAE,UA6BxB,CAAA"}
@@ -1,26 +0,0 @@
1
- import { findMany } from './find/findMany.js';
2
- import { getTableName } from './schema/getTableName.js';
3
- export const findGlobal = async function findGlobal({ slug, locale, req, where }) {
4
- const globalConfig = this.payload.globals.config.find((config)=>config.slug === slug);
5
- const tableName = getTableName({
6
- adapter: this,
7
- config: globalConfig
8
- });
9
- const { docs: [doc] } = await findMany({
10
- adapter: this,
11
- fields: globalConfig.fields,
12
- limit: 1,
13
- locale,
14
- pagination: false,
15
- req,
16
- tableName,
17
- where
18
- });
19
- if (doc) {
20
- doc.globalType = slug;
21
- return doc;
22
- }
23
- return {};
24
- };
25
-
26
- //# sourceMappingURL=findGlobal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/findGlobal.ts"],"sourcesContent":["import type { FindGlobal } from 'payload/database'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const findGlobal: FindGlobal = async function findGlobal(\n this: PostgresAdapter,\n { slug, locale, req, where },\n) {\n const globalConfig = this.payload.globals.config.find((config) => config.slug === slug)\n const tableName = getTableName({\n adapter: this,\n config: globalConfig,\n })\n\n const {\n docs: [doc],\n } = await findMany({\n adapter: this,\n fields: globalConfig.fields,\n limit: 1,\n locale,\n pagination: false,\n req,\n tableName,\n where,\n })\n\n if (doc) {\n doc.globalType = slug\n return doc\n }\n\n return {}\n}\n"],"names":["findMany","getTableName","findGlobal","slug","locale","req","where","globalConfig","payload","globals","config","find","tableName","adapter","docs","doc","fields","limit","pagination","globalType"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAIA,SAASA,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,aAAyB,eAAeA,WAEnD,EAAEC,IAAI,EAAEC,MAAM,EAAEC,GAAG,EAAEC,KAAK,EAAE;IAE5B,MAAMC,eAAe,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAAC,CAACD,SAAWA,OAAOP,IAAI,KAAKA;IAClF,MAAMS,YAAYX,aAAa;QAC7BY,SAAS,IAAI;QACbH,QAAQH;IACV;IAEA,MAAM,EACJO,MAAM,CAACC,IAAI,EACZ,GAAG,MAAMf,SAAS;QACjBa,SAAS,IAAI;QACbG,QAAQT,aAAaS,MAAM;QAC3BC,OAAO;QACPb;QACAc,YAAY;QACZb;QACAO;QACAN;IACF;IAEA,IAAIS,KAAK;QACPA,IAAII,UAAU,GAAGhB;QACjB,OAAOY;IACT;IAEA,OAAO,CAAC;AACV,EAAC"}
@@ -1,3 +0,0 @@
1
- import type { FindGlobalVersions } from 'payload/database';
2
- export declare const findGlobalVersions: FindGlobalVersions;
3
- //# sourceMappingURL=findGlobalVersions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findGlobalVersions.d.ts","sourceRoot":"","sources":["../src/findGlobalVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAU1D,eAAO,MAAM,kBAAkB,EAAE,kBAuChC,CAAA"}
@@ -1,28 +0,0 @@
1
- import { buildVersionGlobalFields } from 'payload/versions';
2
- import { findMany } from './find/findMany.js';
3
- import { getTableName } from './schema/getTableName.js';
4
- export const findGlobalVersions = async function findGlobalVersions({ global, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
5
- const globalConfig = this.payload.globals.config.find(({ slug })=>slug === global);
6
- const sort = typeof sortArg === 'string' ? sortArg : '-createdAt';
7
- const tableName = getTableName({
8
- adapter: this,
9
- config: globalConfig,
10
- versions: true
11
- });
12
- const fields = buildVersionGlobalFields(globalConfig);
13
- return findMany({
14
- adapter: this,
15
- fields,
16
- limit,
17
- locale,
18
- page,
19
- pagination,
20
- req,
21
- skip,
22
- sort,
23
- tableName,
24
- where
25
- });
26
- };
27
-
28
- //# sourceMappingURL=findGlobalVersions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/findGlobalVersions.ts"],"sourcesContent":["import type { FindGlobalVersions } from 'payload/database'\nimport type { PayloadRequest, SanitizedGlobalConfig } from 'payload/types'\n\nimport { buildVersionGlobalFields } from 'payload/versions'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const findGlobalVersions: FindGlobalVersions = async function findGlobalVersions(\n this: PostgresAdapter,\n {\n global,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const globalConfig: SanitizedGlobalConfig = this.payload.globals.config.find(\n ({ slug }) => slug === global,\n )\n const sort = typeof sortArg === 'string' ? sortArg : '-createdAt'\n\n const tableName = getTableName({\n adapter: this,\n config: globalConfig,\n versions: true,\n })\n const fields = buildVersionGlobalFields(globalConfig)\n\n return findMany({\n adapter: this,\n fields,\n limit,\n locale,\n page,\n pagination,\n req,\n skip,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["buildVersionGlobalFields","findMany","getTableName","findGlobalVersions","global","limit","locale","page","pagination","req","skip","sort","sortArg","where","globalConfig","payload","globals","config","find","slug","tableName","adapter","versions","fields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,wBAAwB,QAAQ,mBAAkB;AAI3D,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,qBAAyC,eAAeA,mBAEnE,EACEC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,eAAsC,IAAI,CAACC,OAAO,CAACC,OAAO,CAACC,MAAM,CAACC,IAAI,CAC1E,CAAC,EAAEC,IAAI,EAAE,GAAKA,SAASf;IAEzB,MAAMO,OAAO,OAAOC,YAAY,WAAWA,UAAU;IAErD,MAAMQ,YAAYlB,aAAa;QAC7BmB,SAAS,IAAI;QACbJ,QAAQH;QACRQ,UAAU;IACZ;IACA,MAAMC,SAASvB,yBAAyBc;IAExC,OAAOb,SAAS;QACdoB,SAAS,IAAI;QACbE;QACAlB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAS;QACAP;IACF;AACF,EAAC"}
package/dist/findOne.d.ts DELETED
@@ -1,5 +0,0 @@
1
- import type { FindOneArgs } from 'payload/database';
2
- import type { TypeWithID } from 'payload/types';
3
- import type { PostgresAdapter } from './types.js';
4
- export declare function findOne<T extends TypeWithID>(this: PostgresAdapter, { collection, locale, req, where }: FindOneArgs): Promise<T>;
5
- //# sourceMappingURL=findOne.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findOne.d.ts","sourceRoot":"","sources":["../src/findOne.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACnD,OAAO,KAAK,EAA6C,UAAU,EAAE,MAAM,eAAe,CAAA;AAE1F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAKjD,wBAAsB,OAAO,CAAC,CAAC,SAAS,UAAU,EAChD,IAAI,EAAE,eAAe,EACrB,EAAE,UAAU,EAAE,MAAM,EAAE,GAA0B,EAAE,KAAK,EAAE,EAAE,WAAW,GACrE,OAAO,CAAC,CAAC,CAAC,CAqBZ"}
package/dist/findOne.js DELETED
@@ -1,24 +0,0 @@
1
- import { findMany } from './find/findMany.js';
2
- import { getTableName } from './schema/getTableName.js';
3
- export async function findOne({ collection, locale, req = {}, where }) {
4
- const collectionConfig = this.payload.collections[collection].config;
5
- const tableName = getTableName({
6
- adapter: this,
7
- config: collectionConfig
8
- });
9
- const { docs } = await findMany({
10
- adapter: this,
11
- fields: collectionConfig.fields,
12
- limit: 1,
13
- locale,
14
- page: 1,
15
- pagination: false,
16
- req,
17
- sort: undefined,
18
- tableName,
19
- where
20
- });
21
- return docs?.[0] || null;
22
- }
23
-
24
- //# sourceMappingURL=findOne.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/findOne.ts"],"sourcesContent":["import type { FindOneArgs } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig, TypeWithID } from 'payload/types'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport async function findOne<T extends TypeWithID>(\n this: PostgresAdapter,\n { collection, locale, req = {} as PayloadRequest, where }: FindOneArgs,\n): Promise<T> {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const tableName = getTableName({\n adapter: this,\n config: collectionConfig,\n })\n\n const { docs } = await findMany({\n adapter: this,\n fields: collectionConfig.fields,\n limit: 1,\n locale,\n page: 1,\n pagination: false,\n req,\n sort: undefined,\n tableName,\n where,\n })\n\n return docs?.[0] || null\n}\n"],"names":["findMany","getTableName","findOne","collection","locale","req","where","collectionConfig","payload","collections","config","tableName","adapter","docs","fields","limit","page","pagination","sort","undefined"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;","mappings":"AAKA,SAASA,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,eAAeC,QAEpB,EAAEC,UAAU,EAAEC,MAAM,EAAEC,MAAM,CAAC,CAAmB,EAAEC,KAAK,EAAe;IAEtE,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACN,WAAW,CAACO,MAAM;IAC/F,MAAMC,YAAYV,aAAa;QAC7BW,SAAS,IAAI;QACbF,QAAQH;IACV;IAEA,MAAM,EAAEM,IAAI,EAAE,GAAG,MAAMb,SAAS;QAC9BY,SAAS,IAAI;QACbE,QAAQP,iBAAiBO,MAAM;QAC/BC,OAAO;QACPX;QACAY,MAAM;QACNC,YAAY;QACZZ;QACAa,MAAMC;QACNR;QACAL;IACF;IAEA,OAAOO,MAAM,CAAC,EAAE,IAAI;AACtB"}
@@ -1,3 +0,0 @@
1
- import type { FindVersions } from 'payload/database';
2
- export declare const findVersions: FindVersions;
3
- //# sourceMappingURL=findVersions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findVersions.d.ts","sourceRoot":"","sources":["../src/findVersions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAUpD,eAAO,MAAM,YAAY,EAAE,YAqC1B,CAAA"}
@@ -1,28 +0,0 @@
1
- import { buildVersionCollectionFields } from 'payload/versions';
2
- import { findMany } from './find/findMany.js';
3
- import { getTableName } from './schema/getTableName.js';
4
- export const findVersions = async function findVersions({ collection, limit, locale, page, pagination, req = {}, skip, sort: sortArg, where }) {
5
- const collectionConfig = this.payload.collections[collection].config;
6
- const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort;
7
- const tableName = getTableName({
8
- adapter: this,
9
- config: collectionConfig,
10
- versions: true
11
- });
12
- const fields = buildVersionCollectionFields(collectionConfig);
13
- return findMany({
14
- adapter: this,
15
- fields,
16
- limit,
17
- locale,
18
- page,
19
- pagination,
20
- req,
21
- skip,
22
- sort,
23
- tableName,
24
- where
25
- });
26
- };
27
-
28
- //# sourceMappingURL=findVersions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/findVersions.ts"],"sourcesContent":["import type { FindVersions } from 'payload/database'\nimport type { PayloadRequest, SanitizedCollectionConfig } from 'payload/types'\n\nimport { buildVersionCollectionFields } from 'payload/versions'\n\nimport type { PostgresAdapter } from './types.js'\n\nimport { findMany } from './find/findMany.js'\nimport { getTableName } from './schema/getTableName.js'\n\nexport const findVersions: FindVersions = async function findVersions(\n this: PostgresAdapter,\n {\n collection,\n limit,\n locale,\n page,\n pagination,\n req = {} as PayloadRequest,\n skip,\n sort: sortArg,\n where,\n },\n) {\n const collectionConfig: SanitizedCollectionConfig = this.payload.collections[collection].config\n const sort = typeof sortArg === 'string' ? sortArg : collectionConfig.defaultSort\n\n const tableName = getTableName({\n adapter: this,\n config: collectionConfig,\n versions: true,\n })\n const fields = buildVersionCollectionFields(collectionConfig)\n\n return findMany({\n adapter: this,\n fields,\n limit,\n locale,\n page,\n pagination,\n req,\n skip,\n sort,\n tableName,\n where,\n })\n}\n"],"names":["buildVersionCollectionFields","findMany","getTableName","findVersions","collection","limit","locale","page","pagination","req","skip","sort","sortArg","where","collectionConfig","payload","collections","config","defaultSort","tableName","adapter","versions","fields"],"rangeMappings":";;;;;;;;;;;;;;;;;;;;;;;;;","mappings":"AAGA,SAASA,4BAA4B,QAAQ,mBAAkB;AAI/D,SAASC,QAAQ,QAAQ,qBAAoB;AAC7C,SAASC,YAAY,QAAQ,2BAA0B;AAEvD,OAAO,MAAMC,eAA6B,eAAeA,aAEvD,EACEC,UAAU,EACVC,KAAK,EACLC,MAAM,EACNC,IAAI,EACJC,UAAU,EACVC,MAAM,CAAC,CAAmB,EAC1BC,IAAI,EACJC,MAAMC,OAAO,EACbC,KAAK,EACN;IAED,MAAMC,mBAA8C,IAAI,CAACC,OAAO,CAACC,WAAW,CAACZ,WAAW,CAACa,MAAM;IAC/F,MAAMN,OAAO,OAAOC,YAAY,WAAWA,UAAUE,iBAAiBI,WAAW;IAEjF,MAAMC,YAAYjB,aAAa;QAC7BkB,SAAS,IAAI;QACbH,QAAQH;QACRO,UAAU;IACZ;IACA,MAAMC,SAAStB,6BAA6Bc;IAE5C,OAAOb,SAAS;QACdmB,SAAS,IAAI;QACbE;QACAjB;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;QACAQ;QACAN;IACF;AACF,EAAC"}
package/dist/init.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import type { Init } from 'payload/database';
2
- export declare const init: Init;
3
- //# sourceMappingURL=init.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAW5C,eAAO,MAAM,IAAI,EAAE,IA0FlB,CAAA"}