]> git.jsancho.org Git - bongodb.git/blobdiff - tests/sample.scm
Writing support
[bongodb.git] / tests / sample.scm
index 899c6e0f710582625d1e8f17620c1bd7d67d2a54..bd2cc6ef407a1de2acae76b126a25b661aff0edb 100644 (file)
 (test-assert (collection? col))
 
 ; Insert
-(set! col (insert col '((a . 1) (b . 2)) '((a . 10) (b . 20)) '((a . 1) (b . "hello world"))))
+(set! col (insert col
+                 '((a . 1) (b . 2))
+                 '((a . 10) (b . 20))
+                 '((a . 1) (c . "hello world"))))
 (test-eqv 3 (count col))
 
 ; Search
-(test-eqv 2 (length (find col '((a . 1)))))
-(test-eqv 1 (length (find col '((a . 1) (b . 2)))))
-(test-eqv 0 (length (find col '((a . "test")))))
+(test-eqv 3 (length (find col #t)))
+(test-eqv 2 (length (find col ($eq 'a 1))))
+(test-eqv 1 (length (find col ($and ($eq 'a 1) ($eq 'b 2)))))
+(test-eqv 0 (length (find col ($eq 'c "test"))))
+
+(test-eqv 2 (length (find col ($exists 'b))))
+(test-eqv 2 (length (find col ($not ($exists 'c)))))
+
+; Update
+(set! col (update col ($exists 'c) ($set 'c "test")))
+(test-eqv 1 (length (find col ($eq 'c "test"))))
 
 (test-end "bongodb")