(doc, newEdits, dbOpts)
| 4571 | // Preprocess documents, parse their revisions, assign an id and a |
| 4572 | // revision for new writes that are missing them, etc |
| 4573 | function parseDoc(doc, newEdits, dbOpts) { |
| 4574 | if (!dbOpts) { |
| 4575 | dbOpts = { |
| 4576 | deterministic_revs: true |
| 4577 | }; |
| 4578 | } |
| 4579 | |
| 4580 | var nRevNum; |
| 4581 | var newRevId; |
| 4582 | var revInfo; |
| 4583 | var opts = {status: 'available'}; |
| 4584 | if (doc._deleted) { |
| 4585 | opts.deleted = true; |
| 4586 | } |
| 4587 | |
| 4588 | if (newEdits) { |
| 4589 | if (!doc._id) { |
| 4590 | doc._id = uuid$1(); |
| 4591 | } |
| 4592 | newRevId = rev(doc, dbOpts.deterministic_revs); |
| 4593 | if (doc._rev) { |
| 4594 | revInfo = parseRevisionInfo(doc._rev); |
| 4595 | if (revInfo.error) { |
| 4596 | return revInfo; |
| 4597 | } |
| 4598 | doc._rev_tree = [{ |
| 4599 | pos: revInfo.prefix, |
| 4600 | ids: [revInfo.id, {status: 'missing'}, [[newRevId, opts, []]]] |
| 4601 | }]; |
| 4602 | nRevNum = revInfo.prefix + 1; |
| 4603 | } else { |
| 4604 | doc._rev_tree = [{ |
| 4605 | pos: 1, |
| 4606 | ids : [newRevId, opts, []] |
| 4607 | }]; |
| 4608 | nRevNum = 1; |
| 4609 | } |
| 4610 | } else { |
| 4611 | if (doc._revisions) { |
| 4612 | doc._rev_tree = makeRevTreeFromRevisions(doc._revisions, opts); |
| 4613 | nRevNum = doc._revisions.start; |
| 4614 | newRevId = doc._revisions.ids[0]; |
| 4615 | } |
| 4616 | if (!doc._rev_tree) { |
| 4617 | revInfo = parseRevisionInfo(doc._rev); |
| 4618 | if (revInfo.error) { |
| 4619 | return revInfo; |
| 4620 | } |
| 4621 | nRevNum = revInfo.prefix; |
| 4622 | newRevId = revInfo.id; |
| 4623 | doc._rev_tree = [{ |
| 4624 | pos: nRevNum, |
| 4625 | ids: [newRevId, opts, []] |
| 4626 | }]; |
| 4627 | } |
| 4628 | } |
| 4629 | |
| 4630 | invalidIdError(doc._id); |
no test coverage detected
searching dependent graphs…