@@ -54,13 +54,14 @@ const bulkCreate = async function (req, res, next) {
5454 }
5555
5656 const gatekeep = documents . filter ( d => {
57- // Each item must be valid JSON, but can't be an array.
58- if ( ! isValidJsonObject ( d ) ) return d
57+ // Each item must be valid JSON, but can't be an array.
58+ if ( ! isValidJsonObject ( d ) ) return true
5959
6060 // Items must not have an @id , and in some cases same for id.
6161 const idcheck = _contextid ( d [ "@context" ] ) ? ( d . id ?? d [ "@id" ] ) : d [ "@id" ]
62- if ( idcheck ) return d
63- } )
62+ if ( idcheck ) return true // Reject items WITH an id (creates must not have one)
63+ return false
64+ } )
6465 if ( gatekeep . length > 0 ) {
6566 return next ( createExpressError ( {
6667 message : "All objects in the body of a `/bulkCreate` must be JSON and must not contain a declared identifier property." ,
@@ -98,7 +99,6 @@ const bulkCreate = async function (req, res, next) {
9899 }
99100 try {
100101 let dbResponse = await db . bulkWrite ( bulkOps , { 'ordered' :false } )
101- res . set ( "Content-Type" , "application/json; charset=utf-8" )
102102 res . set ( "Link" , dbResponse . result . insertedIds . map ( r => `${ config . RERUM_ID_PREFIX } ${ r . _id } ` ) ) // https://www.rfc-editor.org/rfc/rfc5988
103103 res . status ( 201 )
104104 const estimatedResults = bulkOps . map ( f => {
@@ -190,7 +190,6 @@ const bulkUpdate = async function (req, res, next) {
190190 }
191191 try {
192192 let dbResponse = await db . bulkWrite ( bulkOps , { 'ordered' :false } )
193- res . set ( "Content-Type" , "application/json; charset=utf-8" )
194193 res . set ( "Link" , dbResponse . result . insertedIds . map ( r => `${ config . RERUM_ID_PREFIX } ${ r . _id } ` ) ) // https://www.rfc-editor.org/rfc/rfc5988
195194 res . status ( 200 )
196195 const estimatedResults = bulkOps . filter ( f => f . insertOne ) . map ( f => {
0 commit comments