(doc, newEdits, dbOpts)
| 4318 | // Preprocess documents, parse their revisions, assign an id and a |
| 4319 | // revision for new writes that are missing them, etc |
| 4320 | function parseDoc(doc, newEdits, dbOpts) { |
| 4321 | if (!dbOpts) { |
| 4322 | dbOpts = { |
| 4323 | deterministic_revs: true |
| 4324 | }; |
| 4325 | } |
| 4326 | |
| 4327 | var nRevNum; |
| 4328 | var newRevId; |
| 4329 | var revInfo; |
| 4330 | var opts = {status: 'available'}; |
| 4331 | if (doc._deleted) { |
| 4332 | opts.deleted = true; |
| 4333 | } |
| 4334 | |
| 4335 | if (newEdits) { |
| 4336 | if (!doc._id) { |
| 4337 | doc._id = uuid$1(); |
| 4338 | } |
| 4339 | newRevId = rev(doc, dbOpts.deterministic_revs); |
| 4340 | if (doc._rev) { |
| 4341 | revInfo = parseRevisionInfo(doc._rev); |
| 4342 | if (revInfo.error) { |
| 4343 | return revInfo; |
| 4344 | } |
| 4345 | doc._rev_tree = [{ |
| 4346 | pos: revInfo.prefix, |
| 4347 | ids: [revInfo.id, {status: 'missing'}, [[newRevId, opts, []]]] |
| 4348 | }]; |
| 4349 | nRevNum = revInfo.prefix + 1; |
| 4350 | } else { |
| 4351 | doc._rev_tree = [{ |
| 4352 | pos: 1, |
| 4353 | ids : [newRevId, opts, []] |
| 4354 | }]; |
| 4355 | nRevNum = 1; |
| 4356 | } |
| 4357 | } else { |
| 4358 | if (doc._revisions) { |
| 4359 | doc._rev_tree = makeRevTreeFromRevisions(doc._revisions, opts); |
| 4360 | nRevNum = doc._revisions.start; |
| 4361 | newRevId = doc._revisions.ids[0]; |
| 4362 | } |
| 4363 | if (!doc._rev_tree) { |
| 4364 | revInfo = parseRevisionInfo(doc._rev); |
| 4365 | if (revInfo.error) { |
| 4366 | return revInfo; |
| 4367 | } |
| 4368 | nRevNum = revInfo.prefix; |
| 4369 | newRevId = revInfo.id; |
| 4370 | doc._rev_tree = [{ |
| 4371 | pos: nRevNum, |
| 4372 | ids: [newRevId, opts, []] |
| 4373 | }]; |
| 4374 | } |
| 4375 | } |
| 4376 | |
| 4377 | invalidIdError(doc._id); |
no test coverage detected
searching dependent graphs…