File tree Expand file tree Collapse file tree 5 files changed +27
-3
lines changed Expand file tree Collapse file tree 5 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 32
32
let some = Ctypes. allocate t
33
33
let none = Ctypes. (from_voidp t null)
34
34
35
- let ptr_of_opt = Option. value ~default: none
36
-
37
35
let get_version () =
38
36
() |> C.Functions. get_version |> Ctypes_std_views. string_of_char_ptr
39
37
Original file line number Diff line number Diff line change 18
18
19
19
val some : t_struct -> t
20
20
val none : t
21
- val ptr_of_opt : t opt
22
21
val t : t_struct Ctypes_static .typ
23
22
val get_version : unit -> string
24
23
val get_major_version : unit -> int
Original file line number Diff line number Diff line change @@ -120,6 +120,14 @@ module Functions (F : Ctypes.FOREIGN) = struct
120
120
@-> ptr (const Bson. t)
121
121
@-> ptr Bson. t @-> ptr Bson.Error. t @-> returning bool )
122
122
123
+ let insert_many =
124
+ foreign " mongoc_collection_insert_many"
125
+ (ptr Types_generated.Collection. t
126
+ @-> ptr (ptr (const Bson. t))
127
+ @-> size_t
128
+ @-> ptr (const Bson. t)
129
+ @-> ptr Bson. t @-> ptr Bson.Error. t @-> returning bool )
130
+
123
131
let drop =
124
132
foreign " mongoc_collection_drop"
125
133
(ptr Types_generated.Collection. t
Original file line number Diff line number Diff line change @@ -91,6 +91,10 @@ and Collection : sig
91
91
(Int64 .t , Bson.Error .t ) result
92
92
93
93
val insert_one : ?opts : Bson .t -> t -> Bson .t -> (Bson .t , Bson.Error .t ) result
94
+
95
+ val insert_many :
96
+ ?opts : Bson .t -> t -> Bson .t list -> (Bson .t , Bson.Error .t ) result
97
+
94
98
val drop : t -> (unit , Bson.Error .t ) result
95
99
val destroy : t -> unit
96
100
val from_database : Database .t -> string -> t
@@ -124,6 +128,17 @@ end = struct
124
128
Ok reply
125
129
else Error error
126
130
131
+ let insert_many ?(opts : Bson.t option ) (coll : t ) (documents : Bson.t list ) :
132
+ (Bson. t , Bson.Error. t ) result =
133
+ let error = Ctypes. (make Bson.Error. t |> addr) in
134
+ let opts = Option. value ~default: Bson. none opts in
135
+ let reply = Ctypes. (make Bson. t |> addr) in
136
+ let length = documents |> List. length |> Unsigned.Size_t. of_int in
137
+ let documents = Ctypes.CArray. (of_list (ptr Bson. t) documents |> start) in
138
+ if C.Functions.Collection. insert_many coll documents length opts reply error
139
+ then Ok reply
140
+ else Error error
141
+
127
142
let drop (coll : t ) =
128
143
let error = Ctypes. (make Bson.Error. t |> addr) in
129
144
if C.Functions.Collection. drop coll error then Ok () else Error error
Original file line number Diff line number Diff line change @@ -99,6 +99,10 @@ and Collection : sig
99
99
(Int64 .t , Bson.Error .t ) result
100
100
101
101
val insert_one : ?opts : Bson .t -> t -> Bson .t -> (Bson .t , Bson.Error .t ) result
102
+
103
+ val insert_many :
104
+ ?opts : Bson .t -> t -> Bson .t list -> (Bson .t , Bson.Error .t ) result
105
+
102
106
val drop : t -> (unit , Bson.Error .t ) result
103
107
val destroy : t -> unit
104
108
val from_database : Database .t -> string -> t
You can’t perform that action at this time.
0 commit comments