| 1696 | } |
| 1697 | |
| 1698 | func (db *DatabaseCollectionWithUser) PutExistingRevWithBody(ctx context.Context, docid string, body Body, docHistory []string, noConflicts bool, docUpdateEvent DocUpdateType) (doc *Document, newRev string, err error) { |
| 1699 | err = validateAPIDocUpdate(body) |
| 1700 | if err != nil { |
| 1701 | return nil, "", err |
| 1702 | } |
| 1703 | |
| 1704 | expiry, _ := body.ExtractExpiry() |
| 1705 | deleted := body.ExtractDeleted() |
| 1706 | revid := body.ExtractRev() |
| 1707 | |
| 1708 | newDoc := &Document{ |
| 1709 | ID: docid, |
| 1710 | Deleted: deleted, |
| 1711 | DocExpiry: expiry, |
| 1712 | RevID: revid, |
| 1713 | } |
| 1714 | |
| 1715 | delete(body, BodyId) |
| 1716 | delete(body, BodyRevisions) |
| 1717 | |
| 1718 | newDoc.SetAttachments(GetBodyAttachments(body)) |
| 1719 | delete(body, BodyAttachments) |
| 1720 | |
| 1721 | newDoc.UpdateBody(body) |
| 1722 | |
| 1723 | doc, newRevID, putExistingRevErr := db.PutExistingRev(ctx, newDoc, docHistory, noConflicts, false, nil, docUpdateEvent) |
| 1724 | |
| 1725 | if putExistingRevErr != nil { |
| 1726 | return nil, "", putExistingRevErr |
| 1727 | } |
| 1728 | |
| 1729 | return doc, newRevID, err |
| 1730 | |
| 1731 | } |
| 1732 | |
| 1733 | // SyncFnDryRun Runs the given document body through a sync function and returns expiry, channels doc was placed in, |
| 1734 | // access map for users, roles, handler errors and sync fn exceptions. |