This repository has been archived by the owner on Dec 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 228
/
Collection.cs
157 lines (119 loc) · 4.46 KB
/
Collection.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
using System;
using System.Collections.Generic;
using System.IO;
using MongoDB.Driver.Connections;
using MongoDB.Driver.Generic;
using MongoDB.Driver.Protocol;
using MongoDB.Driver.Serialization;
namespace MongoDB.Driver
{
/// <summary>
/// <see cref = "IMongoCollection" />
/// </summary>
public class Collection : IMongoCollection
{
Collection<Document> _collection;
public string Database {
get { return _collection.DatabaseName; }
}
public string Name {
get { return _collection.Name; }
}
public string DatabaseName {
get { return _collection.DatabaseName; }
}
public string FullName {
get { return _collection.FullName; }
}
public CollectionMetaData MetaData {
get { return _collection.MetaData; }
}
/// <summary>
/// Initializes a new instance of the <see cref="MongoCollection<T>"/> class.
/// </summary>
/// <param name="connection">The connection.</param>
/// <param name="databaseName">Name of the database.</param>
/// <param name="name">The name.</param>
public Collection(Connection connection, string databaseName, string name)
{
_collection = new Collection<Document>(connection, databaseName, name);
}
public Document FindOne(Document spec){
return _collection.FindOne(spec);
}
public ICursor FindAll(){
return new Cursor(_collection.FindAll());
}
public ICursor Find(string @where){
return new Cursor(_collection.Find(@where));
}
public ICursor Find(Document spec){
return new Cursor(_collection.Find(spec));
}
public ICursor Find(Document spec, int limit, int skip){
return new Cursor(_collection.Find(spec, limit, skip));
}
public ICursor Find(Document spec, int limit, int skip, Document fields){
return new Cursor(_collection.Find(spec, limit, skip, fields));
}
public MapReduce MapReduce(){
return _collection.MapReduce();
}
public MapReduceBuilder MapReduceBuilder(){
return _collection.MapReduceBuilder();
}
public long Count(){
return _collection.Count();
}
public long Count(Document spec){
return _collection.Count(spec);
}
public void Insert(Document doc){
_collection.Insert(doc);
}
public void Insert(Document doc, bool safemode){
_collection.Insert(doc, safemode);
}
public void Insert(IEnumerable<Document> docs){
_collection.Insert(docs);
}
public void Insert(IEnumerable<Document> docs, bool safemode){
_collection.Insert(docs, safemode);
}
public void Delete(Document selector){
_collection.Delete(selector);
}
public void Delete(Document selector, bool safemode){
_collection.Delete(selector, safemode);
}
#region "Updates"
public void Update(Document doc, bool safemode){
_collection.Update(doc,safemode);
}
public void Update(Document doc){
_collection.Update(doc);
}
public void Update(Document doc, Document selector){
_collection.Update(doc,selector);
}
public void Update(Document doc, Document selector, bool safemode){
_collection.Update(doc,selector,safemode);
}
public void Update(Document doc, Document selector, UpdateFlags flags){
_collection.Update(doc,selector,flags);
}
public void Update(Document doc, Document selector, UpdateFlags flags, bool safemode){
_collection.Update(doc,selector,flags,safemode);
}
public void UpdateAll(Document doc, Document selector){
_collection.UpdateAll(doc,selector);
}
public void UpdateAll(Document doc, Document selector, bool safemode){
_collection.UpdateAll(doc,selector,safemode);
}
#endregion
public void Save(Document doc){
_collection.Save(doc);
}
}
}