blob: 17ceb60a036ab9d56d1d2eb9bb9f10e33daf83a1 [file] [log] [blame]
Don Newton379ae252019-04-01 12:17:06 -04001// Copyright (C) MongoDB, Inc. 2017-present.
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may
4// not use this file except in compliance with the License. You may obtain
5// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
7package driver
8
9import (
10 "github.com/mongodb/mongo-go-driver/mongo/options"
11)
12
13// WriteModel is the interface satisfied by all models for bulk writes.
14type WriteModel interface {
15 writeModel()
16}
17
18// InsertOneModel is the write model for insert operations.
19type InsertOneModel struct {
20 Document interface{}
21}
22
23func (InsertOneModel) writeModel() {}
24
25// DeleteOneModel is the write model for delete operations.
26type DeleteOneModel struct {
27 Filter interface{}
28 Collation *options.Collation
29}
30
31func (DeleteOneModel) writeModel() {}
32
33// DeleteManyModel is the write model for deleteMany operations.
34type DeleteManyModel struct {
35 Filter interface{}
36 Collation *options.Collation
37}
38
39func (DeleteManyModel) writeModel() {}
40
41// UpdateModel contains the fields that are shared between the ReplaceOneModel, UpdateOneModel, and UpdateManyModel types
42type UpdateModel struct {
43 Collation *options.Collation
44 Upsert bool
45 UpsertSet bool
46}
47
48// ReplaceOneModel is the write model for replace operations.
49type ReplaceOneModel struct {
50 Filter interface{}
51 Replacement interface{}
52 UpdateModel
53}
54
55func (ReplaceOneModel) writeModel() {}
56
57// UpdateOneModel is the write model for update operations.
58type UpdateOneModel struct {
59 Filter interface{}
60 Update interface{}
61 // default is to not send a value. for servers < 3.6, error raised if value given. for unack writes using opcodes,
62 // error raised if value given
63 ArrayFilters options.ArrayFilters
64 ArrayFiltersSet bool
65 UpdateModel
66}
67
68func (UpdateOneModel) writeModel() {}
69
70// UpdateManyModel is the write model for updateMany operations.
71type UpdateManyModel struct {
72 Filter interface{}
73 Update interface{}
74 // default is to not send a value. for servers < 3.6, error raised if value given. for unack writes using opcodes,
75 // error raised if value given
76 ArrayFilters options.ArrayFilters
77 ArrayFiltersSet bool
78 UpdateModel
79}
80
81func (UpdateManyModel) writeModel() {}