@payloadcms/drizzle 4.0.0-beta.8 → 4.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/transactions/beginTransaction.d.ts.map +1 -1
- package/dist/transactions/beginTransaction.js +13 -5
- package/dist/transactions/beginTransaction.js.map +1 -1
- package/dist/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js +2 -5
- package/dist/transactions/commitTransaction.js.map +1 -1
- package/dist/updateOne.d.ts.map +1 -1
- package/dist/updateOne.js +14 -1
- package/dist/updateOne.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"beginTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/beginTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAM/C,eAAO,MAAM,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"beginTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/beginTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAM/C,eAAO,MAAM,gBAAgB,EAAE,gBAwE9B,CAAA"}
|
|
@@ -8,6 +8,8 @@ export const beginTransaction = async function beginTransaction(options) {
|
|
|
8
8
|
let transaction;
|
|
9
9
|
let transactionReady;
|
|
10
10
|
let transactionFailed;
|
|
11
|
+
let hasTransactionStarted = false;
|
|
12
|
+
const rollbackSignal = new Error('Payload transaction rollback requested');
|
|
11
13
|
// Await initialization here
|
|
12
14
|
// Prevent race conditions where the adapter may be
|
|
13
15
|
// re-initializing, and `this.drizzle` is potentially undefined
|
|
@@ -25,20 +27,26 @@ export const beginTransaction = async function beginTransaction(options) {
|
|
|
25
27
|
return done;
|
|
26
28
|
};
|
|
27
29
|
reject = ()=>{
|
|
28
|
-
|
|
29
|
-
rej();
|
|
30
|
+
rej(rollbackSignal);
|
|
30
31
|
return done;
|
|
31
32
|
};
|
|
32
33
|
transactionReady();
|
|
33
34
|
});
|
|
34
35
|
}, options || this.transactionOptions).catch((err)=>{
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
if (!hasTransactionStarted) {
|
|
37
|
+
// Connection failed before callback ran - reject instead of hanging forever
|
|
38
|
+
transactionFailed(err);
|
|
39
|
+
} else if (err !== rollbackSignal) {
|
|
40
|
+
throw err;
|
|
41
|
+
}
|
|
37
42
|
});
|
|
38
43
|
// Need to wait until the transaction is ready
|
|
39
44
|
// before binding its `resolve` and `reject` methods below
|
|
40
45
|
await new Promise((res, rej)=>{
|
|
41
|
-
transactionReady =
|
|
46
|
+
transactionReady = ()=>{
|
|
47
|
+
hasTransactionStarted = true;
|
|
48
|
+
res();
|
|
49
|
+
};
|
|
42
50
|
transactionFailed = rej;
|
|
43
51
|
});
|
|
44
52
|
this.sessions[id] = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/beginTransaction.ts"],"sourcesContent":["import type { BeginTransaction } from 'payload'\n\nimport { v4 as uuid } from 'uuid'\n\nimport type { DrizzleAdapter, DrizzleTransaction } from '../types.js'\n\nexport const beginTransaction: BeginTransaction = async function beginTransaction(\n this: DrizzleAdapter,\n options: DrizzleAdapter['transactionOptions'],\n) {\n let id\n try {\n id = uuid()\n\n let reject: () => Promise<void>\n let resolve: () => Promise<void>\n let transaction: DrizzleTransaction\n\n let transactionReady: () => void\n let transactionFailed: (err: unknown) => void\n\n // Await initialization here\n // Prevent race conditions where the adapter may be\n // re-initializing, and `this.drizzle` is potentially undefined\n await this.initializing\n\n // Drizzle only exposes a transactions API that is sufficient if you\n // can directly pass around the `tx` argument. But our operations are spread\n // over many files and we don't want to pass the `tx` around like that,\n // so instead, we \"lift\" up the `resolve` and `reject` methods\n // and will call them in our respective transaction methods\n const done = this.drizzle\n .transaction(async (tx) => {\n transaction = tx\n await new Promise<void>((res, rej) => {\n resolve = () => {\n res()\n return done\n }\n reject = () => {\n
|
|
1
|
+
{"version":3,"sources":["../../src/transactions/beginTransaction.ts"],"sourcesContent":["import type { BeginTransaction } from 'payload'\n\nimport { v4 as uuid } from 'uuid'\n\nimport type { DrizzleAdapter, DrizzleTransaction } from '../types.js'\n\nexport const beginTransaction: BeginTransaction = async function beginTransaction(\n this: DrizzleAdapter,\n options: DrizzleAdapter['transactionOptions'],\n) {\n let id\n try {\n id = uuid()\n\n let reject: () => Promise<void>\n let resolve: () => Promise<void>\n let transaction: DrizzleTransaction\n\n let transactionReady: () => void\n let transactionFailed: (err: unknown) => void\n let hasTransactionStarted = false\n const rollbackSignal = new Error('Payload transaction rollback requested')\n\n // Await initialization here\n // Prevent race conditions where the adapter may be\n // re-initializing, and `this.drizzle` is potentially undefined\n await this.initializing\n\n // Drizzle only exposes a transactions API that is sufficient if you\n // can directly pass around the `tx` argument. But our operations are spread\n // over many files and we don't want to pass the `tx` around like that,\n // so instead, we \"lift\" up the `resolve` and `reject` methods\n // and will call them in our respective transaction methods\n const done = this.drizzle\n .transaction(async (tx) => {\n transaction = tx\n await new Promise<void>((res, rej) => {\n resolve = () => {\n res()\n return done\n }\n reject = () => {\n rej(rollbackSignal)\n return done\n }\n transactionReady()\n })\n }, options || this.transactionOptions)\n .catch((err) => {\n if (!hasTransactionStarted) {\n // Connection failed before callback ran - reject instead of hanging forever\n transactionFailed(err)\n } else if (err !== rollbackSignal) {\n throw err\n }\n })\n\n // Need to wait until the transaction is ready\n // before binding its `resolve` and `reject` methods below\n await new Promise<void>((res, rej) => {\n transactionReady = () => {\n hasTransactionStarted = true\n res()\n }\n transactionFailed = rej\n })\n\n this.sessions[id] = {\n db: transaction,\n reject,\n resolve,\n }\n } catch (err) {\n this.payload.logger.error({ err, msg: `Error: cannot begin transaction: ${err.message}` })\n throw new Error(`Error: cannot begin transaction: ${err.message}`)\n }\n\n return id\n}\n"],"names":["v4","uuid","beginTransaction","options","id","reject","resolve","transaction","transactionReady","transactionFailed","hasTransactionStarted","rollbackSignal","Error","initializing","done","drizzle","tx","Promise","res","rej","transactionOptions","catch","err","sessions","db","payload","logger","error","msg","message"],"mappings":"AAEA,SAASA,MAAMC,IAAI,QAAQ,OAAM;AAIjC,OAAO,MAAMC,mBAAqC,eAAeA,iBAE/DC,OAA6C;IAE7C,IAAIC;IACJ,IAAI;QACFA,KAAKH;QAEL,IAAII;QACJ,IAAIC;QACJ,IAAIC;QAEJ,IAAIC;QACJ,IAAIC;QACJ,IAAIC,wBAAwB;QAC5B,MAAMC,iBAAiB,IAAIC,MAAM;QAEjC,4BAA4B;QAC5B,mDAAmD;QACnD,+DAA+D;QAC/D,MAAM,IAAI,CAACC,YAAY;QAEvB,oEAAoE;QACpE,4EAA4E;QAC5E,uEAAuE;QACvE,8DAA8D;QAC9D,2DAA2D;QAC3D,MAAMC,OAAO,IAAI,CAACC,OAAO,CACtBR,WAAW,CAAC,OAAOS;YAClBT,cAAcS;YACd,MAAM,IAAIC,QAAc,CAACC,KAAKC;gBAC5Bb,UAAU;oBACRY;oBACA,OAAOJ;gBACT;gBACAT,SAAS;oBACPc,IAAIR;oBACJ,OAAOG;gBACT;gBACAN;YACF;QACF,GAAGL,WAAW,IAAI,CAACiB,kBAAkB,EACpCC,KAAK,CAAC,CAACC;YACN,IAAI,CAACZ,uBAAuB;gBAC1B,4EAA4E;gBAC5ED,kBAAkBa;YACpB,OAAO,IAAIA,QAAQX,gBAAgB;gBACjC,MAAMW;YACR;QACF;QAEF,8CAA8C;QAC9C,0DAA0D;QAC1D,MAAM,IAAIL,QAAc,CAACC,KAAKC;YAC5BX,mBAAmB;gBACjBE,wBAAwB;gBACxBQ;YACF;YACAT,oBAAoBU;QACtB;QAEA,IAAI,CAACI,QAAQ,CAACnB,GAAG,GAAG;YAClBoB,IAAIjB;YACJF;YACAC;QACF;IACF,EAAE,OAAOgB,KAAK;QACZ,IAAI,CAACG,OAAO,CAACC,MAAM,CAACC,KAAK,CAAC;YAAEL;YAAKM,KAAK,CAAC,iCAAiC,EAAEN,IAAIO,OAAO,EAAE;QAAC;QACxF,MAAM,IAAIjB,MAAM,CAAC,iCAAiC,EAAEU,IAAIO,OAAO,EAAE;IACnE;IAEA,OAAOzB;AACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commitTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/commitTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,eAAO,MAAM,iBAAiB,EAAE,
|
|
1
|
+
{"version":3,"file":"commitTransaction.d.ts","sourceRoot":"","sources":["../../src/transactions/commitTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAEhD,eAAO,MAAM,iBAAiB,EAAE,iBAkB/B,CAAA"}
|
|
@@ -8,11 +8,8 @@ export const commitTransaction = async function commitTransaction(incomingID = '
|
|
|
8
8
|
// Delete from registry FIRST to prevent race conditions
|
|
9
9
|
// This ensures other operations can't retrieve this session while we're ending it
|
|
10
10
|
delete this.sessions[transactionID];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} catch (_) {
|
|
14
|
-
await session.reject();
|
|
15
|
-
}
|
|
11
|
+
// Drizzle handles rollback if commit fails; preserve the error for the caller.
|
|
12
|
+
await session.resolve();
|
|
16
13
|
};
|
|
17
14
|
|
|
18
15
|
//# sourceMappingURL=commitTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/transactions/commitTransaction.ts"],"sourcesContent":["import type { CommitTransaction } from 'payload'\n\nexport const commitTransaction: CommitTransaction = async function commitTransaction(\n incomingID = '',\n) {\n const transactionID = incomingID instanceof Promise ? await incomingID : incomingID\n\n // if the session was deleted it has already been aborted\n if (!this.sessions[transactionID]) {\n return\n }\n\n const session = this.sessions[transactionID]\n\n // Delete from registry FIRST to prevent race conditions\n // This ensures other operations can't retrieve this session while we're ending it\n delete this.sessions[transactionID]\n\n
|
|
1
|
+
{"version":3,"sources":["../../src/transactions/commitTransaction.ts"],"sourcesContent":["import type { CommitTransaction } from 'payload'\n\nexport const commitTransaction: CommitTransaction = async function commitTransaction(\n incomingID = '',\n) {\n const transactionID = incomingID instanceof Promise ? await incomingID : incomingID\n\n // if the session was deleted it has already been aborted\n if (!this.sessions[transactionID]) {\n return\n }\n\n const session = this.sessions[transactionID]\n\n // Delete from registry FIRST to prevent race conditions\n // This ensures other operations can't retrieve this session while we're ending it\n delete this.sessions[transactionID]\n\n // Drizzle handles rollback if commit fails; preserve the error for the caller.\n await session.resolve()\n}\n"],"names":["commitTransaction","incomingID","transactionID","Promise","sessions","session","resolve"],"mappings":"AAEA,OAAO,MAAMA,oBAAuC,eAAeA,kBACjEC,aAAa,EAAE;IAEf,MAAMC,gBAAgBD,sBAAsBE,UAAU,MAAMF,aAAaA;IAEzE,yDAAyD;IACzD,IAAI,CAAC,IAAI,CAACG,QAAQ,CAACF,cAAc,EAAE;QACjC;IACF;IAEA,MAAMG,UAAU,IAAI,CAACD,QAAQ,CAACF,cAAc;IAE5C,wDAAwD;IACxD,kFAAkF;IAClF,OAAO,IAAI,CAACE,QAAQ,CAACF,cAAc;IAEnC,+EAA+E;IAC/E,MAAMG,QAAQC,OAAO;AACvB,EAAC"}
|
package/dist/updateOne.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateOne.d.ts","sourceRoot":"","sources":["../src/updateOne.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"updateOne.d.ts","sourceRoot":"","sources":["../src/updateOne.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAiBxC,eAAO,MAAM,SAAS,EAAE,SAmJvB,CAAA"}
|
package/dist/updateOne.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { eq } from 'drizzle-orm';
|
|
1
2
|
import toSnakeCase from 'to-snake-case';
|
|
2
3
|
import { buildQuery } from './queries/buildQuery.js';
|
|
3
4
|
import { selectDistinct } from './queries/selectDistinct.js';
|
|
@@ -28,6 +29,9 @@ export const updateOne = async function updateOne({ id, collection: collectionSl
|
|
|
28
29
|
// queries keep resolving a matching id first and then update that row unconditionally
|
|
29
30
|
whereToUpdate = joins.length === 0 ? where : undefined;
|
|
30
31
|
if (options.atomic === true) {
|
|
32
|
+
if (joins.length > 0) {
|
|
33
|
+
throw new Error('Atomic where updates do not support predicates that require joins');
|
|
34
|
+
}
|
|
31
35
|
if (!shouldUseOptimizedUpsertRow({
|
|
32
36
|
data,
|
|
33
37
|
fields: collection.flattenedFields
|
|
@@ -44,8 +48,17 @@ export const updateOne = async function updateOne({ id, collection: collectionSl
|
|
|
44
48
|
if (arraysToPush && Object.keys(arraysToPush).length) {
|
|
45
49
|
throw new Error('Atomic where updates do not support array operations');
|
|
46
50
|
}
|
|
51
|
+
const table = this.tables[tableName];
|
|
52
|
+
const matchingRowQuery = db.select({
|
|
53
|
+
id: table.id
|
|
54
|
+
}).from(table).where(where).limit(1);
|
|
55
|
+
// PostgreSQL must lock the candidate before applying LIMIT so a waiting caller can
|
|
56
|
+
// continue to another match if a concurrent update makes the first row ineligible.
|
|
57
|
+
// NO KEY UPDATE permits concurrent foreign-key checks on the candidate.
|
|
58
|
+
// SQLite serializes writers and does not support SELECT ... FOR UPDATE.
|
|
59
|
+
const matchingRow = this.name === 'postgres' ? matchingRowQuery.for('no key update') : matchingRowQuery;
|
|
47
60
|
markWrite(this);
|
|
48
|
-
const docs = await db.update(
|
|
61
|
+
const docs = await db.update(table).set(row).where(eq(table.id, matchingRow)).returning();
|
|
49
62
|
if (!docs[0]) {
|
|
50
63
|
return null;
|
|
51
64
|
}
|
package/dist/updateOne.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { LibSQLDatabase } from 'drizzle-orm/libsql'\nimport type { UpdateOne } from 'payload'\n\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter } from './types.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { selectDistinct } from './queries/selectDistinct.js'\nimport { transform } from './transform/read/index.js'\nimport { transformForWrite } from './transform/write/index.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { shouldUseOptimizedUpsertRow } from './upsertRow/shouldUseOptimizedUpsertRow.js'\nimport { getPrimaryDb } from './utilities/getPrimaryDb.js'\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { markWrite } from './utilities/readAfterWrite.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: DrizzleAdapter,\n {\n id,\n collection: collectionSlug,\n data,\n joins: joinQuery,\n locale,\n options = { upsert: false },\n req,\n returning,\n select,\n where: whereArg,\n },\n) {\n const collection = this.payload.collections[collectionSlug].config\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n let idToUpdate = id\n let whereToUpdate: SQL<unknown> | undefined\n\n const db = getPrimaryDb(this, await getTransaction(this, req))\n\n if (!idToUpdate) {\n const { joins, selectFields, where } = buildQuery({\n adapter: this,\n fields: collection.flattenedFields,\n locale,\n tableName,\n where: whereArg,\n })\n // A `where` that needs joins cannot be applied to the UPDATE statement itself, so those\n // queries keep resolving a matching id first and then update that row unconditionally\n whereToUpdate = joins.length === 0 ? where : undefined\n\n if (options.atomic === true) {\n if (!shouldUseOptimizedUpsertRow({ data, fields: collection.flattenedFields })) {\n throw new Error('Atomic where updates only support fields stored on the main table')\n }\n\n const { arraysToPush, row } = transformForWrite({\n adapter: this,\n data,\n enableAtomicWrites: true,\n fields: collection.flattenedFields,\n tableName,\n })\n\n if (arraysToPush && Object.keys(arraysToPush).length) {\n throw new Error('Atomic where updates do not support array operations')\n }\n\n markWrite(this)\n\n const docs = await (db as LibSQLDatabase)\n .update(
|
|
1
|
+
{"version":3,"sources":["../src/updateOne.ts"],"sourcesContent":["import type { SQL } from 'drizzle-orm'\nimport type { LibSQLDatabase } from 'drizzle-orm/libsql'\nimport type { UpdateOne } from 'payload'\n\nimport { eq } from 'drizzle-orm'\nimport toSnakeCase from 'to-snake-case'\n\nimport type { DrizzleAdapter, PostgresDB } from './types.js'\n\nimport { buildQuery } from './queries/buildQuery.js'\nimport { selectDistinct } from './queries/selectDistinct.js'\nimport { transform } from './transform/read/index.js'\nimport { transformForWrite } from './transform/write/index.js'\nimport { upsertRow } from './upsertRow/index.js'\nimport { shouldUseOptimizedUpsertRow } from './upsertRow/shouldUseOptimizedUpsertRow.js'\nimport { getPrimaryDb } from './utilities/getPrimaryDb.js'\nimport { getTransaction } from './utilities/getTransaction.js'\nimport { markWrite } from './utilities/readAfterWrite.js'\n\nexport const updateOne: UpdateOne = async function updateOne(\n this: DrizzleAdapter,\n {\n id,\n collection: collectionSlug,\n data,\n joins: joinQuery,\n locale,\n options = { upsert: false },\n req,\n returning,\n select,\n where: whereArg,\n },\n) {\n const collection = this.payload.collections[collectionSlug].config\n const tableName = this.tableNameMap.get(toSnakeCase(collection.slug))\n let idToUpdate = id\n let whereToUpdate: SQL<unknown> | undefined\n\n const db = getPrimaryDb(this, await getTransaction(this, req))\n\n if (!idToUpdate) {\n const { joins, selectFields, where } = buildQuery({\n adapter: this,\n fields: collection.flattenedFields,\n locale,\n tableName,\n where: whereArg,\n })\n // A `where` that needs joins cannot be applied to the UPDATE statement itself, so those\n // queries keep resolving a matching id first and then update that row unconditionally\n whereToUpdate = joins.length === 0 ? where : undefined\n\n if (options.atomic === true) {\n if (joins.length > 0) {\n throw new Error('Atomic where updates do not support predicates that require joins')\n }\n\n if (!shouldUseOptimizedUpsertRow({ data, fields: collection.flattenedFields })) {\n throw new Error('Atomic where updates only support fields stored on the main table')\n }\n\n const { arraysToPush, row } = transformForWrite({\n adapter: this,\n data,\n enableAtomicWrites: true,\n fields: collection.flattenedFields,\n tableName,\n })\n\n if (arraysToPush && Object.keys(arraysToPush).length) {\n throw new Error('Atomic where updates do not support array operations')\n }\n\n const table = this.tables[tableName]\n const matchingRowQuery = (db as PostgresDB)\n .select({ id: table.id })\n .from(table)\n .where(where)\n .limit(1)\n\n // PostgreSQL must lock the candidate before applying LIMIT so a waiting caller can\n // continue to another match if a concurrent update makes the first row ineligible.\n // NO KEY UPDATE permits concurrent foreign-key checks on the candidate.\n // SQLite serializes writers and does not support SELECT ... FOR UPDATE.\n const matchingRow =\n this.name === 'postgres' ? matchingRowQuery.for('no key update') : matchingRowQuery\n\n markWrite(this)\n\n const docs = await (db as LibSQLDatabase)\n .update(table)\n .set(row)\n .where(eq(table.id, matchingRow))\n .returning()\n\n if (!docs[0]) {\n return null\n }\n\n return transform({\n adapter: this,\n config: this.payload.config,\n data: docs[0],\n fields: collection.flattenedFields,\n joinQuery: false,\n tableName,\n })\n }\n\n // selectDistinct will only return if there are joins\n const selectDistinctResult = await selectDistinct({\n adapter: this,\n db,\n joins,\n query: ({ query }) => query.limit(1),\n selectFields,\n tableName,\n where,\n })\n\n if (selectDistinctResult?.[0]?.id) {\n idToUpdate = selectDistinctResult?.[0]?.id\n // If id wasn't passed but `where` without any joins, retrieve it with findFirst\n } else if (whereArg && !joins.length) {\n const table = this.tables[tableName]\n\n const docsToUpdate = await (db as LibSQLDatabase)\n .select({\n id: table.id,\n })\n .from(table)\n .where(where)\n .limit(1)\n idToUpdate = docsToUpdate?.[0]?.id\n }\n }\n\n if (!idToUpdate && !options.upsert) {\n // TODO: In 4.0, if returning === false, we should differentiate between:\n // - No document found to update\n // - Document found, but returning === false\n return null\n }\n\n const result = await upsertRow({\n id: idToUpdate,\n adapter: this,\n collectionSlug,\n data,\n db,\n fields: collection.flattenedFields,\n ignoreResult: returning === false,\n joinQuery,\n operation: 'update',\n req,\n select,\n tableName,\n where: whereToUpdate,\n })\n\n if (returning === false) {\n return null\n }\n\n return result\n}\n"],"names":["eq","toSnakeCase","buildQuery","selectDistinct","transform","transformForWrite","upsertRow","shouldUseOptimizedUpsertRow","getPrimaryDb","getTransaction","markWrite","updateOne","id","collection","collectionSlug","data","joins","joinQuery","locale","options","upsert","req","returning","select","where","whereArg","payload","collections","config","tableName","tableNameMap","get","slug","idToUpdate","whereToUpdate","db","selectFields","adapter","fields","flattenedFields","length","undefined","atomic","Error","arraysToPush","row","enableAtomicWrites","Object","keys","table","tables","matchingRowQuery","from","limit","matchingRow","name","for","docs","update","set","selectDistinctResult","query","docsToUpdate","result","ignoreResult","operation"],"mappings":"AAIA,SAASA,EAAE,QAAQ,cAAa;AAChC,OAAOC,iBAAiB,gBAAe;AAIvC,SAASC,UAAU,QAAQ,0BAAyB;AACpD,SAASC,cAAc,QAAQ,8BAA6B;AAC5D,SAASC,SAAS,QAAQ,4BAA2B;AACrD,SAASC,iBAAiB,QAAQ,6BAA4B;AAC9D,SAASC,SAAS,QAAQ,uBAAsB;AAChD,SAASC,2BAA2B,QAAQ,6CAA4C;AACxF,SAASC,YAAY,QAAQ,8BAA6B;AAC1D,SAASC,cAAc,QAAQ,gCAA+B;AAC9D,SAASC,SAAS,QAAQ,gCAA+B;AAEzD,OAAO,MAAMC,YAAuB,eAAeA,UAEjD,EACEC,EAAE,EACFC,YAAYC,cAAc,EAC1BC,IAAI,EACJC,OAAOC,SAAS,EAChBC,MAAM,EACNC,UAAU;IAAEC,QAAQ;AAAM,CAAC,EAC3BC,GAAG,EACHC,SAAS,EACTC,MAAM,EACNC,OAAOC,QAAQ,EAChB;IAED,MAAMZ,aAAa,IAAI,CAACa,OAAO,CAACC,WAAW,CAACb,eAAe,CAACc,MAAM;IAClE,MAAMC,YAAY,IAAI,CAACC,YAAY,CAACC,GAAG,CAAC9B,YAAYY,WAAWmB,IAAI;IACnE,IAAIC,aAAarB;IACjB,IAAIsB;IAEJ,MAAMC,KAAK3B,aAAa,IAAI,EAAE,MAAMC,eAAe,IAAI,EAAEY;IAEzD,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json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/drizzle",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.9",
|
|
4
4
|
"description": "A library of shared functions used by different payload database adapters",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"@types/pg": "8.20.0",
|
|
56
56
|
"@types/to-snake-case": "1.0.0",
|
|
57
57
|
"esbuild": "0.27.1",
|
|
58
|
-
"payload": "4.0.0-beta.
|
|
58
|
+
"payload": "4.0.0-beta.9"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"payload": "4.0.0-beta.
|
|
61
|
+
"payload": "4.0.0-beta.9"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "pnpm build:swc && pnpm build:types",
|