File tree Expand file tree Collapse file tree 1 file changed +37
-4
lines changed Expand file tree Collapse file tree 1 file changed +37
-4
lines changed Original file line number Diff line number Diff line change @@ -125,26 +125,59 @@ public function id($_id = false)
125
125
}
126
126
127
127
/**
128
- * Add pending document
128
+ * Add pending document for insert
129
129
* @param array $data
130
130
*/
131
131
public function insert ($ data = [])
132
132
{
133
133
134
+ $ this ->action ('index ' , $ data );
135
+
136
+ }
137
+
138
+ /**
139
+ * Add pending document for update
140
+ * @param array $data
141
+ */
142
+ public function update ($ data = [])
143
+ {
144
+
145
+ $ this ->action ('update ' , $ data );
146
+
147
+ }
148
+
149
+ /**
150
+ * Add pending document for deletion
151
+ */
152
+ public function delete ()
153
+ {
154
+
155
+ $ this ->action ('delete ' );
156
+
157
+ }
158
+
159
+ /**
160
+ * Add pending document abstract action
161
+ * @param string $actionType
162
+ * @param array $data
163
+ */
164
+ public function action ($ actionType , $ data = [])
165
+ {
134
166
$ this ->body ["body " ][] = [
135
167
136
- ' index ' => [
168
+ $ actionType => [
137
169
'_index ' => $ this ->getIndex (),
138
170
'_type ' => $ this ->getType (),
139
171
'_id ' => $ this ->_id
140
172
]
141
173
142
174
];
143
175
144
- $ this ->body ["body " ][] = $ data ;
176
+ if (!empty ($ data )) {
177
+ $ this ->body ["body " ][] = $ data ;
178
+ }
145
179
146
180
$ this ->reset ();
147
-
148
181
}
149
182
150
183
/**
You can’t perform that action at this time.
0 commit comments