#include "SampleLib.h"
int main(int argc, char **argv)
{
const char *collectionName, *key;
dpiSodaOperOptions options;
dpiSampleParams *params;
dpiSodaColl *coll;
uint64_t numDocs;
dpiSodaDb *db;
if (argc != 3) {
fprintf(stderr, "Usage: DemoGetSodaDoc <name> <key>\n");
return 1;
}
collectionName = argv[1];
key = argv[2];
db = dpiSamples_getSodaDb();
if (dpiSodaDb_openCollection(db, collectionName, strlen(collectionName),
DPI_SODA_FLAGS_DEFAULT, &coll) < 0)
return dpiSamples_showError();
if (!coll) {
printf("No collection named %s\n", collectionName);
return 1;
}
params = dpiSamples_getParams();
if (dpiContext_initSodaOperOptions(params->context, &options) < 0)
return dpiSamples_showError();
options.key = key;
options.keyLength = strlen(key);
if (dpiSodaColl_remove(coll, &options, DPI_SODA_FLAGS_ATOMIC_COMMIT,
&numDocs) < 0)
return dpiSamples_showError();
printf("%" PRIu64 " documents removed.\n", numDocs);
dpiSodaColl_release(coll);
dpiSodaDb_release(db);
printf("Done.\n");
return 0;
}