Example #1
0
SEXP R_mongo_collection_find(SEXP ptr_col, SEXP ptr_query, SEXP ptr_opts) {
  mongoc_collection_t *col = r2col(ptr_col);
  bson_t *query = r2bson(ptr_query);
  bson_t *opts = r2bson(ptr_opts);
  mongoc_cursor_t *c = mongoc_collection_find_with_opts(col, query, opts, NULL);
  return cursor2r(c, ptr_col);
}
Example #2
0
SEXP R_mongo_collection_find_indexes(SEXP ptr_col) {
  mongoc_collection_t *col = r2col(ptr_col);
  bson_error_t err;

  mongoc_cursor_t *c = mongoc_collection_find_indexes_with_opts (col, NULL);
  if(mongoc_cursor_error(c, &err))
    stop(err.message);

  return cursor2r(c, ptr_col);
}
Example #3
0
SEXP R_mongo_collection_find_indexes(SEXP ptr_col) {
  mongoc_collection_t *col = r2col(ptr_col);
  bson_error_t err;

  mongoc_cursor_t *c = mongoc_collection_find_indexes (col, &err);
  if(!c)
    stop(err.message);

  return cursor2r(c);
}
Example #4
0
SEXP R_mongo_collection_command(SEXP ptr_col, SEXP ptr_cmd, SEXP no_timeout){
  mongoc_collection_t *col = r2col(ptr_col);
  bson_t *cmd = r2bson(ptr_cmd);

  mongoc_query_flags_t flags = MONGOC_QUERY_NONE;
  if(Rf_asLogical(no_timeout))
    flags += MONGOC_QUERY_NO_CURSOR_TIMEOUT;

  mongoc_cursor_t *c = mongoc_collection_command(col, flags, 0, 0, 0, cmd, NULL, NULL);
  if(!c)
    stop("Error executing command.");
  return cursor2r(c, ptr_col);
}
Example #5
0
SEXP R_mongo_collection_aggregate(SEXP ptr_col, SEXP ptr_pipeline, SEXP no_timeout) {
  mongoc_collection_t *col = r2col(ptr_col);
  bson_t *pipeline = r2bson(ptr_pipeline);

  mongoc_query_flags_t flags = MONGOC_QUERY_NONE;
  if(asLogical(no_timeout))
    flags += MONGOC_QUERY_NO_CURSOR_TIMEOUT;

  mongoc_cursor_t *c = mongoc_collection_aggregate (col, flags, pipeline, NULL, NULL);
  if(!c)
    stop("Error executing pipeline.");
  return cursor2r(c);
}
Example #6
0
SEXP R_mongo_collection_find(SEXP ptr_col, SEXP ptr_query, SEXP ptr_fields, SEXP skip, SEXP limit, SEXP no_timeout) {
  mongoc_collection_t *col = r2col(ptr_col);
  bson_t *query = r2bson(ptr_query);
  bson_t *fields = r2bson(ptr_fields);

  mongoc_query_flags_t flags = MONGOC_QUERY_NONE;
  if(asLogical(no_timeout))
    flags += MONGOC_QUERY_NO_CURSOR_TIMEOUT;

  mongoc_cursor_t *c = mongoc_collection_find(col, flags, asInteger(skip), asInteger(limit),
    0, query, fields, NULL);

  return cursor2r(c);
}