Skip to content

Commit 7afe1bd

Browse files
committed
feat: match custom collection schema payload in loadtest-public-api.js
1 parent 564a5b1 commit 7afe1bd

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

scripts/loadtest-public-api.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,17 +109,26 @@ async function startLoadTest() {
109109

110110
// Test 4: Data Write / Document Insert
111111
if (!skipData) {
112+
let insertBody = {
113+
Title: 'Load Test Post',
114+
userId: '6a650c2b6c4cae6fbf3204e6'
115+
};
116+
if (args.payload) {
117+
try {
118+
insertBody = typeof args.payload === 'string' ? JSON.parse(args.payload) : args.payload;
119+
} catch (e) {
120+
console.warn('⚠️ Failed to parse --payload JSON. Using default payload.');
121+
}
122+
}
123+
112124
await runBenchmark(`4. Document Insert (POST /api/data/${collection})`, {
113125
url: `${target}/api/data/${collection}`,
114126
method: 'POST',
115127
headers: {
116128
'x-api-key': apiKey,
117129
'content-type': 'application/json',
118130
},
119-
body: {
120-
title: 'Load Test Post',
121-
content: 'Benchmarking database write performance',
122-
},
131+
body: insertBody,
123132
});
124133
}
125134

0 commit comments

Comments
 (0)