MONGOC_MATCHER_T(3)

πŸ“¦
version 1.23.1 Β· 2 versions
, in debian bookworm

πŸ’… MONGOC_MATCHER_T(3) πŸ’…

okay bestie, welcome to libmongoc's little corner for mongoc_matcher_t β€” yes the manual name is literally libmongoc, she's the whole vibe πŸ’–


✨ NAME ✨

mongoc_matcher_t β€” mongoc_matcher_t

Client-side document matching abstraction 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

typedef struct _mongoc_matcher_t mongoc_matcher_t;

So mongoc_matcher_t is giving you a reduced-interface for matching BSON documents on the client side. like, you don't need the whole server for this, she's doing it herself πŸ’…

She can do the basics, and by basics I mean: $in, $nin, $eq, $neq, $gt, $gte, $lt, and $lte. periodt.

⚠️ WARNING: mongoc_matcher_t does not currently support the full spectrum of query operations that the MongoDB server supports. so don't come for her about the fancy stuff, she said what she said 😭

πŸ’€ DEPRECATED πŸ’€

⚠️ WARNING: mongoc_matcher_t is deprecated and will be removed in version 2.0. not me telling you to start planning the goodbye party rn πŸ™ˆ

πŸŽ€ EXAMPLE πŸŽ€

Filter a sequence of BSON documents from STDIN based on a query πŸ”₯

#include <bson/bson.h>
#include <mongoc/mongoc.h>
#include <stdio.h>

int
main (int argc, char *argv[])
{
   mongoc_matcher_t *matcher;
   bson_reader_t *reader;
   const bson_t *bson;
   bson_t *spec;
   char *str;
   int fd;

   mongoc_init ();

#ifdef _WIN32
   fd = fileno (stdin);
#else
   fd = STDIN_FILENO;
#endif

   reader = bson_reader_new_from_fd (fd, false);

   spec = BCON_NEW ("hello", "world");
   matcher = mongoc_matcher_new (spec, NULL);

   while ((bson = bson_reader_read (reader, NULL))) {
      if (mongoc_matcher_match (matcher, bson)) {
         str = bson_as_canonical_extended_json (bson, NULL);
         printf ("%s\n", str);
         bson_free (str);
      }
   }

   bson_reader_destroy (reader);
   bson_destroy (spec);

   mongoc_cleanup ();

   return 0;
}

like, she reads from STDIN, checks each doc against the spec, and prints the ones that ate πŸ‘‘


πŸ‘‘ AUTHOR πŸ‘‘

MongoDB, Inc 🫢


2017-present, MongoDB, Inc


and that's the whole page bestie ✨ this was version 1.23.1, dated Apr 27, 2026, and she's still serving MONGOC_MATCHER_T(3) energy πŸ’œ no cap, go write some matchers πŸ§šπŸ“

πŸ“¦ where this page comes from