I'm working on project where i have to prepopulate array. I need to update this function so that arrays 'time' and 'values' become arrays with sub-arrays full of '0' but i can't figute it out how am i suppose to do this. I'll be grateful for any help!
int prepopulate(mongoc_collection_t *collection, int nvalues) {
bson_t *doc, *values, *time;
bson_error_t error;
bson_oid_t oid;
doc = bson_new ();
values = bson_new ();
time = bson_new();
bson_oid_init (&oid, NULL);
BSON_APPEND_OID (doc, "_id", &oid);
BSON_APPEND_INT64 (doc, "series", 0);
BSON_APPEND_INT64 (doc, "prevEnd", 0);
BSON_APPEND_INT64 (doc, "nextStart", 0);
int i;
for (i=0; i<nvalues; i++) {
BSON_APPEND_INT64(values, "0", 0);
BSON_APPEND_INT64(time, "0", 0);
}
bson_append_array (doc, "value", -1, values);
bson_append_array (doc, "time", -1, time);
int res = mongoc_collection_insert(collection, MONGOC_INSERT_NONE, doc,
NULL, &error);
bson_destroy (doc);
bson_destroy (values);
bson_destroy (time);
return res;
}