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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
use super::where_::Where;
use crate::Comparison;
use crate::DbValue;
use crate::QueryCondition;
use crate::QueryConditionData;
use crate::QueryConditionLogic;
use crate::QueryConditionModifier;
use crate::QueryId;
use crate::SearchQuery;
use crate::SearchQueryAlgorithm;
use crate::db::db_key_order::DbKeyOrders;
use crate::query::query_condition::KeyValueComparison;
#[cfg(feature = "api")]
pub trait SearchQueryBuilder: agdb::api_def::TypeDefinition {
fn search_mut(&mut self) -> &mut SearchQuery;
}
#[cfg(not(feature = "api"))]
pub trait SearchQueryBuilder {
fn search_mut(&mut self) -> &mut SearchQuery;
}
/// Search builder query.
#[cfg_attr(feature = "api", derive(agdb::TypeDef))]
pub struct Search<T: SearchQueryBuilder>(pub T);
/// Search builder query that lets you choose search origin
/// and other parameters.
#[cfg_attr(feature = "api", derive(agdb::TypeDef))]
pub struct SearchFrom<T: SearchQueryBuilder>(pub T);
/// Search builder query that lets you choose search destination
/// and other parameters.
#[cfg_attr(feature = "api", derive(agdb::TypeDef))]
pub struct SearchTo<T: SearchQueryBuilder>(pub T);
/// Search builder query that lets you choose an index to search
/// instead of the graph search.
#[cfg_attr(feature = "api", derive(agdb::TypeDef))]
pub struct SearchIndex<T: SearchQueryBuilder> {
pub index: DbValue,
pub query: T,
}
/// Search builder query that lets you choose a a value to find
/// in the index.
#[cfg_attr(feature = "api", derive(agdb::TypeDef))]
pub struct SearchIndexValue<T: SearchQueryBuilder>(pub T);
/// Search builder query that lets you choose limit and offset.
#[cfg_attr(feature = "api", derive(agdb::TypeDef))]
pub struct SearchOrderBy<T: SearchQueryBuilder>(pub T);
/// Search builder query that lets you choose conditions.
#[cfg_attr(feature = "api", derive(agdb::TypeDef))]
pub struct SelectLimit<T: SearchQueryBuilder>(pub T);
/// Search builder query that lets you choose limit.
#[cfg_attr(feature = "api", derive(agdb::TypeDef))]
pub struct SelectOffset<T: SearchQueryBuilder>(pub T);
/// Search builder query that lets you choose search origin
/// and other parameters.
#[cfg_attr(feature = "api", derive(agdb::TypeDef))]
pub struct SearchAlgorithm<T: SearchQueryBuilder>(pub T);
#[cfg_attr(feature = "api", agdb::impl_def())]
impl<T: SearchQueryBuilder> Search<T> {
/// Use breadth-first (BFS) search algorithm. This option is redundant as
/// BFS is the default. BFS means each level of the graph is examined in full
/// before advancing to the next level. E.g. all edges coming from a node,
/// then all the nodes connected to them in the same order. Then all edges
/// coming from each of those nodes etc.
///
/// Options:
///
/// ```
/// use agdb::QueryBuilder;
///
/// QueryBuilder::search().breadth_first().from(1);
/// QueryBuilder::search().breadth_first().to(1);
/// ```
pub fn breadth_first(mut self) -> SearchAlgorithm<T> {
self.0.search_mut().algorithm = SearchQueryAlgorithm::BreadthFirst;
SearchAlgorithm(self.0)
}
/// Use depth-first (DFS) search algorithm. DFS means each element is followed
/// up to its dead end (or already visited element) before examining a next element.
/// The algorithm is exhausting each path before backtracking one step at a time to
/// try another when it reaches the end in any direction.
///
/// Options:
///
/// ```
/// use agdb::QueryBuilder;
///
/// QueryBuilder::search().depth_first().from(1);
/// QueryBuilder::search().depth_first().to(1);
/// ```
pub fn depth_first(mut self) -> SearchAlgorithm<T> {
self.0.search_mut().algorithm = SearchQueryAlgorithm::DepthFirst;
SearchAlgorithm(self.0)
}
/// Searches all elements (nodes & edges) in the database disregarding the graph
/// structure or any relationships between elements. This performs linear search
/// through the entire database which may be prohibitively expensive. Consider
/// using `limit()`.
///
/// Note: While the full range of conitions can be used some conditions do not
/// make logical sense (e.g. distance, beyond, edge_count etc.).
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().elements().order_by([DbKeyOrder::Asc("k".into())]);
/// QueryBuilder::search().elements().offset(5);
/// QueryBuilder::search().elements().limit(10);
/// QueryBuilder::search().elements().where_();
/// ```
pub fn elements(mut self) -> SearchTo<T> {
self.0.search_mut().algorithm = SearchQueryAlgorithm::Elements;
SearchTo(self.0)
}
/// Searches an index specified by `key`. This is to provide fast lookup of
/// specific elements with particular key-value pair.
///
/// Options:
///
/// ```
/// use agdb::QueryBuilder;
///
/// QueryBuilder::search().index("k").value(1);
/// ```
pub fn index<K: Into<DbValue>>(self, key: K) -> SearchIndex<T> {
SearchIndex {
index: key.into(),
query: self.0,
}
}
/// Sets the origin of the search.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().from(1).query();
/// QueryBuilder::search().from(1).to(2);
/// QueryBuilder::search().from(1).order_by([DbKeyOrder::Asc("k".into())]);
/// QueryBuilder::search().from(1).offset(5);
/// QueryBuilder::search().from(1).limit(10);
/// QueryBuilder::search().from(1).where_();
/// ```
pub fn from<I: Into<QueryId>>(mut self, id: I) -> SearchFrom<T> {
self.0.search_mut().origin = id.into();
SearchFrom(self.0)
}
/// Reverses the search setting only the destination. Reverse search
/// follows the edges in reverse (to<-from).
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().to(1).order_by([DbKeyOrder::Asc("k".into())]);
/// QueryBuilder::search().to(1).offset(5);
/// QueryBuilder::search().to(1).limit(10);
/// QueryBuilder::search().to(1).where_();
/// ```
pub fn to<I: Into<QueryId>>(mut self, id: I) -> SearchTo<T> {
self.0.search_mut().destination = id.into();
SearchTo(self.0)
}
}
#[cfg_attr(feature = "api", agdb::impl_def())]
impl<T: SearchQueryBuilder> SearchAlgorithm<T> {
/// Sets the origin of the search.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().depth_first().from(1).query();
/// QueryBuilder::search().depth_first().from(1).to(2);
/// QueryBuilder::search().depth_first().from(1).order_by([DbKeyOrder::Asc("k".into())]);
/// QueryBuilder::search().depth_first().from(1).offset(5);
/// QueryBuilder::search().depth_first().from(1).limit(10);
/// QueryBuilder::search().depth_first().from(1).where_();
/// ```
pub fn from<I: Into<QueryId>>(mut self, id: I) -> SearchFrom<T> {
self.0.search_mut().origin = id.into();
SearchFrom(self.0)
}
/// Reverses the search setting only the destination. Reverse search
/// follows the edges in reverse (to<-x<-from).
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().depth_first().to(1).order_by([DbKeyOrder::Asc("k".into())]);
/// QueryBuilder::search().depth_first().to(1).offset(5);
/// QueryBuilder::search().depth_first().to(1).limit(10);
/// QueryBuilder::search().depth_first().to(1).where_();
/// ```
pub fn to<I: Into<QueryId>>(mut self, id: I) -> SearchTo<T> {
self.0.search_mut().destination = id.into();
SearchTo(self.0)
}
}
#[cfg_attr(feature = "api", agdb::impl_def())]
impl<T: SearchQueryBuilder> SearchFrom<T> {
/// Sets the limit to number of ids returned. If during the search
/// the `limit + offset` is hit the search ends and the result is returned.
/// However when doing a path search or requesting ordering of the result
/// the search is first completed before the limit is applied.
///
/// Options:
///
/// ```
/// use agdb::QueryBuilder;
///
/// QueryBuilder::search().from(1).limit(10).query();
/// QueryBuilder::search().from(1).limit(10).where_();
/// ```
pub fn limit(mut self, value: u64) -> SelectLimit<T> {
self.0.search_mut().limit = value;
SelectLimit(self.0)
}
/// Sets the offset to the ids returned. If during the search
/// the `limit + offset` is hit the search ends and the result is
/// returned. The `offset` ids will be skipped in the result.
/// However when doing a path search or requesting ordering of the
/// result the search is first completed before the limit is applied.
///
/// Options:
///
/// ```
/// use agdb::QueryBuilder;
///
/// QueryBuilder::search().from(1).offset(10).query();
/// QueryBuilder::search().from(1).offset(10).limit(5);
/// QueryBuilder::search().from(1).offset(10).where_();
/// ```
pub fn offset(mut self, value: u64) -> SelectOffset<T> {
self.0.search_mut().offset = value;
SelectOffset(self.0)
}
/// Orders the result by `keys`.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().from(1).order_by([DbKeyOrder::Asc("k".into())]).query();
/// QueryBuilder::search().from(1).order_by([DbKeyOrder::Asc("k".into())]).offset(10);
/// QueryBuilder::search().from(1).order_by([DbKeyOrder::Asc("k".into())]).limit(5);
/// QueryBuilder::search().from(1).order_by([DbKeyOrder::Asc("k".into())]).where_();
/// ```
pub fn order_by<K: Into<DbKeyOrders>>(mut self, keys: K) -> SearchOrderBy<T> {
self.0.search_mut().order_by = Into::<DbKeyOrders>::into(keys).0;
SearchOrderBy(self.0)
}
/// Returns the built query object.
pub fn query(self) -> T {
self.0
}
/// Sets the destination (to) and changes the search algorithm to path search
/// using the A* algorithm.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().from(1).to(2).query();
/// QueryBuilder::search().from(1).to(2).order_by([DbKeyOrder::Asc("k".into())]);
/// QueryBuilder::search().from(1).to(2).offset(10);
/// QueryBuilder::search().from(1).to(2).limit(5);
/// QueryBuilder::search().from(1).to(2).where_();
/// ```
pub fn to<I: Into<QueryId>>(mut self, id: I) -> SearchTo<T> {
self.0.search_mut().destination = id.into();
SearchTo(self.0)
}
/// Starts the condition builder.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, CountComparison};
///
/// QueryBuilder::search().from(1).where_().node();
/// QueryBuilder::search().from(1).where_().edge();
/// QueryBuilder::search().from(1).where_().distance(1);
/// QueryBuilder::search().from(1).where_().ids(1);
/// QueryBuilder::search().from(1).where_().keys("k");
/// QueryBuilder::search().from(1).where_().key("k");
/// QueryBuilder::search().from(1).where_().edge_count(1);
/// QueryBuilder::search().from(1).where_().edge_count_from(CountComparison::LessThan(1));
/// QueryBuilder::search().from(1).where_().edge_count_to(CountComparison::GreaterThan(1));
/// QueryBuilder::search().from(1).where_().where_();
/// QueryBuilder::search().from(1).where_().not();
/// QueryBuilder::search().from(1).where_().beyond();
/// QueryBuilder::search().from(1).where_().not_beyond();
/// ```
pub fn where_(self) -> Where<T> {
Where::new(self.0)
}
}
#[cfg_attr(feature = "api", agdb::impl_def())]
impl<T: SearchQueryBuilder> SearchOrderBy<T> {
/// Sets the limit to number of ids returned. If during the search
/// the `limit + offset` is hit the search ends and the result is returned.
/// However when doing a path search or requesting ordering of the result
/// the search is first completed before the limit is applied.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().from(1).order_by([DbKeyOrder::Asc("k".into())]).limit(10).query();
/// QueryBuilder::search().from(1).order_by([DbKeyOrder::Asc("k".into())]).limit(10).where_();
/// ```
pub fn limit(mut self, value: u64) -> SelectLimit<T> {
self.0.search_mut().limit = value;
SelectLimit(self.0)
}
/// Sets the offset to the ids returned. If during the search
/// the `limit + offset` is hit the search ends and the result is
/// returned. The `offset` ids will be skipped in the result.
/// However when doing a path search or requesting ordering of the
/// result the search is first completed before the limit is applied.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().from(1).order_by([DbKeyOrder::Asc("k".into())]).offset(10).query();
/// QueryBuilder::search().from(1).order_by([DbKeyOrder::Asc("k".into())]).offset(10).limit(5);
/// QueryBuilder::search().from(1).order_by([DbKeyOrder::Asc("k".into())]).offset(10).where_();
/// ```
pub fn offset(mut self, value: u64) -> SelectOffset<T> {
self.0.search_mut().offset = value;
SelectOffset(self.0)
}
/// Returns the built query object.
pub fn query(self) -> T {
self.0
}
/// Starts the condition builder.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, CountComparison};
///
/// QueryBuilder::search().from(1).where_().node();
/// QueryBuilder::search().from(1).where_().edge();
/// QueryBuilder::search().from(1).where_().distance(2);
/// QueryBuilder::search().from(1).where_().neighbor();
/// QueryBuilder::search().from(1).where_().ids(1);
/// QueryBuilder::search().from(1).where_().keys("k");
/// QueryBuilder::search().from(1).where_().key("k");
/// QueryBuilder::search().from(1).where_().edge_count(CountComparison::LessThan(1));
/// QueryBuilder::search().from(1).where_().edge_count_from(1);
/// QueryBuilder::search().from(1).where_().edge_count_to(CountComparison::GreaterThan(1));
/// QueryBuilder::search().from(1).where_().where_();
/// QueryBuilder::search().from(1).where_().not();
/// QueryBuilder::search().from(1).where_().beyond();
/// QueryBuilder::search().from(1).where_().not_beyond();
/// ```
pub fn where_(self) -> Where<T> {
Where::new(self.0)
}
}
#[cfg_attr(feature = "api", agdb::impl_def())]
impl<T: SearchQueryBuilder> SearchTo<T> {
/// Sets the limit to number of ids returned. If during the search
/// the `limit + offset` is hit the search ends and the result is returned.
/// However when doing a path search or requesting ordering of the result
/// the search is first completed before the limit is applied.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().to(1).order_by([DbKeyOrder::Asc("k".into())]).limit(10).query();
/// QueryBuilder::search().to(1).order_by([DbKeyOrder::Asc("k".into())]).limit(10).where_();
/// ```
pub fn limit(mut self, value: u64) -> SelectLimit<T> {
self.0.search_mut().limit = value;
SelectLimit(self.0)
}
/// Sets the offset to the ids returned. If during the search
/// the `limit + offset` is hit the search ends and the result is
/// returned. The `offset` ids will be skipped in the result.
/// However when doing a path search or requesting ordering of the
/// result the search is first completed before the limit is applied.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().to(1).order_by([DbKeyOrder::Asc("k".into())]).offset(10).query();
/// QueryBuilder::search().to(1).order_by([DbKeyOrder::Asc("k".into())]).offset(10).limit(5);
/// QueryBuilder::search().to(1).order_by([DbKeyOrder::Asc("k".into())]).offset(10).where_();
/// ```
pub fn offset(mut self, value: u64) -> SelectOffset<T> {
self.0.search_mut().offset = value;
SelectOffset(self.0)
}
/// Sets the offset to the ids returned. If during the search
/// the `limit + offset` is hit the search ends and the result is
/// returned. The `offset` ids will be skipped in the result.
/// However when doing a path search or requesting ordering of the
/// result the search is first completed before the limit is applied.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().to(1).order_by([DbKeyOrder::Asc("k".into())]).offset(10).query();
/// QueryBuilder::search().to(1).order_by([DbKeyOrder::Asc("k".into())]).offset(10).limit(5);
/// QueryBuilder::search().to(1).order_by([DbKeyOrder::Asc("k".into())]).offset(10).where_();
/// ```
pub fn order_by<K: Into<DbKeyOrders>>(mut self, keys: K) -> SearchOrderBy<T> {
self.0.search_mut().order_by = Into::<DbKeyOrders>::into(keys).0;
SearchOrderBy(self.0)
}
/// Returns the built `SearchQuery` object.
pub fn query(self) -> T {
self.0
}
/// Starts the condition builder.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, CountComparison};
///
/// QueryBuilder::search().from(1).where_().node();
/// QueryBuilder::search().from(1).where_().edge();
/// QueryBuilder::search().from(1).where_().distance(2);
/// QueryBuilder::search().from(1).where_().neighbor();
/// QueryBuilder::search().from(1).where_().ids(1);
/// QueryBuilder::search().from(1).where_().keys("k");
/// QueryBuilder::search().from(1).where_().key("k");
/// QueryBuilder::search().from(1).where_().edge_count(1);
/// QueryBuilder::search().from(1).where_().edge_count_from(CountComparison::GreaterThan(1));
/// QueryBuilder::search().from(1).where_().edge_count_to(CountComparison::LessThan(1));
/// QueryBuilder::search().from(1).where_().where_();
/// QueryBuilder::search().from(1).where_().not();
/// QueryBuilder::search().from(1).where_().beyond();
/// QueryBuilder::search().from(1).where_().not_beyond();
/// ```
pub fn where_(self) -> Where<T> {
Where::new(self.0)
}
}
#[cfg_attr(feature = "api", agdb::impl_def())]
impl<T: SearchQueryBuilder> SelectLimit<T> {
/// Returns the built query object.
pub fn query(self) -> T {
self.0
}
/// Starts the condition builder.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, CountComparison};
///
/// QueryBuilder::search().from(1).where_().node();
/// QueryBuilder::search().from(1).where_().edge();
/// QueryBuilder::search().from(1).where_().distance(2);
/// QueryBuilder::search().from(1).where_().neighbor();
/// QueryBuilder::search().from(1).where_().ids(1);
/// QueryBuilder::search().from(1).where_().keys("k");
/// QueryBuilder::search().from(1).where_().key("k");
/// QueryBuilder::search().from(1).where_().edge_count(1);
/// QueryBuilder::search().from(1).where_().edge_count_from(CountComparison::GreaterThan(1));
/// QueryBuilder::search().from(1).where_().edge_count_to(CountComparison::LessThan(1));
/// QueryBuilder::search().from(1).where_().where_();
/// QueryBuilder::search().from(1).where_().not();
/// QueryBuilder::search().from(1).where_().beyond();
/// QueryBuilder::search().from(1).where_().not_beyond();
/// ```
pub fn where_(self) -> Where<T> {
Where::new(self.0)
}
}
#[cfg_attr(feature = "api", agdb::impl_def())]
impl<T: SearchQueryBuilder> SelectOffset<T> {
/// Sets the limit to number of ids returned. If during the search
/// the `limit + offset` is hit the search ends and the result is returned.
/// However when doing a path search or requesting ordering of the result
/// the search is first completed before the limit is applied.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, DbKeyOrder};
///
/// QueryBuilder::search().from(1).offset(10).limit(10).query();
/// QueryBuilder::search().from(1).offset(10).limit(10).where_();
/// ```
pub fn limit(mut self, value: u64) -> SelectLimit<T> {
self.0.search_mut().limit = value;
SelectLimit(self.0)
}
/// Returns the built query object.
pub fn query(self) -> T {
self.0
}
/// Starts the condition builder.
///
/// Options:
///
/// ```
/// use agdb::{QueryBuilder, CountComparison};
///
/// QueryBuilder::search().from(1).where_().node();
/// QueryBuilder::search().from(1).where_().edge();
/// QueryBuilder::search().from(1).where_().distance(2);
/// QueryBuilder::search().from(1).where_().neighbor();
/// QueryBuilder::search().from(1).where_().ids(1);
/// QueryBuilder::search().from(1).where_().keys("k");
/// QueryBuilder::search().from(1).where_().key("k");
/// QueryBuilder::search().from(1).where_().edge_count(1);
/// QueryBuilder::search().from(1).where_().edge_count_from(CountComparison::GreaterThan(1));
/// QueryBuilder::search().from(1).where_().edge_count_to(CountComparison::LessThan(1));
/// QueryBuilder::search().from(1).where_().where_();
/// QueryBuilder::search().from(1).where_().not();
/// QueryBuilder::search().from(1).where_().beyond();
/// QueryBuilder::search().from(1).where_().not_beyond();
/// ```
pub fn where_(self) -> Where<T> {
Where::new(self.0)
}
}
#[cfg_attr(feature = "api", agdb::impl_def())]
impl<T: SearchQueryBuilder> SearchIndex<T> {
/// Sets the value to be searched in the index.
pub fn value<V: Into<DbValue>>(mut self, value: V) -> SearchIndexValue<T> {
self.query.search_mut().algorithm = SearchQueryAlgorithm::Index;
self.query.search_mut().conditions.push(QueryCondition {
data: QueryConditionData::KeyValue(KeyValueComparison {
key: self.index,
value: Comparison::Equal(value.into()),
}),
logic: QueryConditionLogic::And,
modifier: QueryConditionModifier::None,
});
SearchIndexValue(self.query)
}
}
#[cfg_attr(feature = "api", agdb::impl_def())]
impl<T: SearchQueryBuilder> SearchIndexValue<T> {
/// Returns the built q object.
pub fn query(self) -> T {
self.0
}
}