Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
27 lines
882 B
Plaintext
27 lines
882 B
Plaintext
import toSnakeCase from 'to-snake-case';
|
|
import { upsertRow } from './upsertRow/index.js';
|
|
import { getTransaction } from './utilities/getTransaction.js';
|
|
export const create = async function create({ collection: collectionSlug, customID, data, req, returning, select }) {
|
|
const collection = this.payload.collections[collectionSlug].config;
|
|
const tableName = this.tableNameMap.get(toSnakeCase(collection.slug));
|
|
const db = await getTransaction(this, req);
|
|
const result = await upsertRow({
|
|
adapter: this,
|
|
collectionSlug,
|
|
customID,
|
|
data,
|
|
db,
|
|
fields: collection.flattenedFields,
|
|
ignoreResult: returning === false,
|
|
operation: 'create',
|
|
req,
|
|
select,
|
|
tableName
|
|
});
|
|
if (returning === false) {
|
|
return null;
|
|
}
|
|
return result;
|
|
};
|
|
|
|
//# sourceMappingURL=create.js.map |