(ctx context.Context)
| 336 | } |
| 337 | |
| 338 | func (doc *Document) BodyWithSpecialProperties(ctx context.Context) ([]byte, error) { |
| 339 | bodyBytes, err := doc.BodyBytes(ctx) |
| 340 | if err != nil { |
| 341 | return nil, err |
| 342 | } |
| 343 | |
| 344 | kvPairs := []base.KVPair{ |
| 345 | {Key: BodyId, Val: doc.ID}, |
| 346 | {Key: BodyRev, Val: doc.GetRevTreeID()}, |
| 347 | } |
| 348 | |
| 349 | if doc.IsDeleted() { |
| 350 | kvPairs = append(kvPairs, base.KVPair{Key: BodyDeleted, Val: true}) |
| 351 | } |
| 352 | |
| 353 | if len(doc.Attachments()) > 0 { |
| 354 | kvPairs = append(kvPairs, base.KVPair{Key: BodyAttachments, Val: doc.Attachments()}) |
| 355 | } |
| 356 | |
| 357 | bodyBytes, err = base.InjectJSONProperties(bodyBytes, kvPairs...) |
| 358 | if err != nil { |
| 359 | return nil, err |
| 360 | } |
| 361 | |
| 362 | return bodyBytes, nil |
| 363 | } |
| 364 | |
| 365 | // Returns a new empty document. |
| 366 | func NewDocument(docid string) *Document { |
no test coverage detected