|
Grassroots Infrastructure
The Grassroots Infrastructure is a suite of computing tools to help users and developers use scientific data infrastructure that can easily be interconnected.
|
#include "mongoc.h"#include "typedefs.h"#include "jansson.h"#include "mongodb_library.h"#include "operation.h"Go to the source code of this file.
Data Structures | |
| struct | MongoTool |
| A MongoTool is a datatype that allows access to the data stored within a MongoDB instance. More... | |
Macros | |
| #define | MONGO_OID_STRING_BUFFER_SIZE (25) |
Functions | |
| bool | AddBSONDocumentToJSONArray (const bson_t *document_p, void *data_p) |
| Convert a BSON document and add it to a JSON array. More... | |
| int | PrintBSONToLog (const uint32 level, const char *filename_s, const int line_number, const bson_t *bson_p, const char *message_s,...) |
| Print the JSON representation of a BSON fragment to the log Stream. More... | |
| int | PrintBSONToErrors (const uint32 level, const char *filename_s, const int line_number, const bson_t *bson_p, const char *message_s,...) |
| Print the JSON representation of a BSON fragment to the errors Stream. More... | |
| void | LogBSONOid (const bson_oid_t *bson_p, const int level, const char *const filename_s, const int line_number, const char *const prefix_s) |
| Print a BSON id to the log Stream. More... | |
| void | LogAllBSON (const bson_t *bson_p, const int level, const char *const file_s, const int line, const char *const prefix_s) |
| Print the JSON representation of a BSON object and all of its children and members to the log Stream. More... | |
| bson_t * | GenerateQuery (const json_t *json_p) |
| Create a BSON query from a JSON fragment. More... | |
| json_t * | ConvertBSONValueToJSON (const bson_value_t *value_p) |
| Convert a BSON object into its equivalent JSON type. More... | |
| json_t * | ConvertBSONToJSON (const bson_t *bson_p) |
| Create a new JSON fragment from a given BSON one. More... | |
| bool | InsertMongoData (MongoTool *tool_p, const json_t *values_p, bson_t **reply_pp, bson_error_t *error_p) |
| bool | InsertMongoDataAsBSON (MongoTool *tool_p, const bson_t *doc_p, bson_t **reply_pp, bson_error_t *error_p) |
| bool | RunMongoCommand (MongoTool *tool_p, bson_t *command_p, bson_t **reply_pp) |
| bool | RemoveMongoDocumentsByBSON (MongoTool *tool_p, const bson_t *selector_p, const bool remove_first_match_only_flag) |
| bson_t * | ConvertJSONToBSON (const json_t *json_p) |
| Create a new BSON fragment from a given JSON one. More... | |
| char * | GetBSONOidAsString (const bson_oid_t *id_p) |
| void | FreeBSONOidString (char *id_s) |
| bson_oid_t * | GetBSONOidFromString (const char *id_s) |
| bool | SaveMongoData (MongoTool *mongo_p, const json_t *data_to_save_p, const char *collection_s, bson_t *selector_p) |
| bool | SaveMongoDataWithTimestamp (MongoTool *mongo_p, json_t *data_to_save_p, const char *collection_s, bson_t *selector_p, const char *timestamp_key_s) |
| bool | SaveAndBackupMongoDataWithTimestamp (MongoTool *mongo_p, json_t *data_to_save_p, const char *collection_s, const char *backup_collection_s, const char *id_key_s, bson_t *selector_p, const char *timestamp_key_s) |
| bool | SaveMongoDataFromBSON (MongoTool *mongo_p, const bson_t *data_to_save_p, const char *collection_s, bson_t *selector_p) |
| bool | SaveAndBackupMongoData (MongoTool *mongo_p, const json_t *data_to_save_p, const char *collection_s, const char *backup_collection_s, const char *id_key_s, bson_t *selector_p) |
| bool | SaveAndBackupMongoDataFromBSON (MongoTool *mongo_p, const bson_t *data_to_save_p, const char *collection_s, const char *backup_collection_s, const char *id_key_s, bson_t *selector_p) |
| bool | SetMongoDataAsBSON (MongoTool *tool_p, bson_t *selector_p, const bson_t *doc_p, bson_t **reply_pp) |
| bool | UnsetMongoDataAsBSON (MongoTool *tool_p, bson_t *selector_p, const bson_t *doc_p, bson_t **reply_pp) |
| bool | UpdateMongoDataAsBSON (MongoTool *tool_p, const char *const update_s, bson_t *selector_p, const bson_t *doc_p, bson_t **reply_pp) |
| bool | SetMongoDataAsBSONForGivenId (MongoTool *tool_p, bson_oid_t *id_p, bson_t *update_p, bson_t **reply_pp) |
| bool | SetMongoData (MongoTool *tool_p, bson_t *selector_p, const json_t *values_p, bson_t **reply_pp) |
| bson_oid_t * | GetNewBSONOid (void) |
| bson_oid_t * | GetNewUnitialisedBSONOid (void) |
| bson_oid_t * | CopyBSONOid (const bson_oid_t *src_p) |
| void | FreeBSONOid (bson_oid_t *id_p) |
| bson_t * | AllocateBSON (void) |
| void | FreeBSON (bson_t *bson_p) |
| bool | GetMongoIdFromJSON (const json_t *data_p, bson_oid_t *id_p) |
| bool | GetNamedIdFromJSON (const json_t *data_p, const char *const key_s, bson_oid_t *id_p) |
| const char * | GetNamedIdAsStringFromJSON (const json_t *data_p, const char *const key_s) |
| bool | GetIdFromJSONKeyValuePair (const json_t *id_val_p, bson_oid_t *id_p) |
| bool | AddCompoundIdToJSON (json_t *data_p, bson_oid_t *id_p) |
| bool | AddNamedCompoundIdToJSON (json_t *data_p, bson_oid_t *id_p, const char *key_s) |
| bool | AddCompoundIdToJSONArray (json_t *array_p, const bson_oid_t *id_p) |
| bool | AddIdToJSON (json_t *data_p, bson_oid_t *id_p, const char *key_s) |
| bool | AddQueryTerm (bson_t *query_p, const char *key_s, const char *value_s, bool regex_flag) |
| int64 | GetNumberOfMongoResults (MongoTool *tool_p, bson_t *query_p, bson_t *extra_opts_p) |
| OperationStatus | ProcessMongoResults (MongoTool *tool_p, bson_t *query_p, bson_t *extra_opts_p, bool(*process_bson_fn)(const bson_t *document_p, void *data_p), void *data_p) |
Variables | |
| const char * | MONGO_OID_KEY_S = "$oid" |
| const char * | MONGO_TIMESTAMP_S = "modified" |
| The key for specifying the timestamp of a saved piece of data. More... | |
| #define MONGO_OID_STRING_BUFFER_SIZE (25) |
| bool AddBSONDocumentToJSONArray | ( | const bson_t * | document_p, |
| void * | data_p | ||
| ) |
Convert a BSON document and add it to a JSON array.
| document_p | The BSON document to extract the values from. |
| data_p | The JSON array to add the values to |
true if the values were added successfully, false otherwise. | int PrintBSONToLog | ( | const uint32 | level, |
| const char * | filename_s, | ||
| const int | line_number, | ||
| const bson_t * | bson_p, | ||
| const char * | message_s, | ||
| ... | |||
| ) |
Print the JSON representation of a BSON fragment to the log Stream.
| level | The Stream level to specify when printing this. |
| filename_s | The name of the file which will be specified with this message. |
| line_number | The line number which will be specified with this message. |
| bson_p | The BSON fragment to print. |
| prefix_s | An optional string to print in the stream prior to the BSON representation. |
| int PrintBSONToErrors | ( | const uint32 | level, |
| const char * | filename_s, | ||
| const int | line_number, | ||
| const bson_t * | bson_p, | ||
| const char * | message_s, | ||
| ... | |||
| ) |
Print the JSON representation of a BSON fragment to the errors Stream.
| level | The Stream level to specify when printing this. |
| filename_s | The name of the file which will be specified with this message. |
| line_number | The line number which will be specified with this message. |
| bson_p | The BSON fragment to print. |
| prefix_s | An optional string to print in the stream prior to the BSON representation. |
| void LogBSONOid | ( | const bson_oid_t * | bson_p, |
| const int | level, | ||
| const char *const | filename_s, | ||
| const int | line_number, | ||
| const char *const | prefix_s | ||
| ) |
Print a BSON id to the log Stream.
| bson_p | The BSON fragment to print. |
| level | The Stream level to specify when printing this. |
| filename_s | The name of the file which will be specified with this message. |
| line_number | The line number which will be specified with this message. |
| prefix_s | An optional string to print in the stream prior to the BSON representation. |
| void LogAllBSON | ( | const bson_t * | bson_p, |
| const int | level, | ||
| const char *const | file_s, | ||
| const int | line, | ||
| const char *const | prefix_s | ||
| ) |
Print the JSON representation of a BSON object and all of its children and members to the log Stream.
| bson_p | The BSON fragment to print. |
| level | The Stream level to specify when printing this. |
| file_s | The name of the file which will be specified with this message. |
| line | The line number which will be specified with this message. |
| prefix_s | An optional string to print in the stream prior to the BSON representation. |
| bson_t* GenerateQuery | ( | const json_t * | json_p | ) |
Create a BSON query from a JSON fragment.
| json_p | The JSON fragment to create the query from. If the given fragment is not an object or array, treat the statement as key = value. If it is an array, treat it as an "in" query. If it is an object, the value can have the following fields: |
key: one of "=", "<", "<=", ">", ">=", "in", "range", "not" value: can be single value or array. For a "range" key, it will be an array of 2 elements that are the inclusive lower and upper bounds.
NULL upon error. | json_t* ConvertBSONValueToJSON | ( | const bson_value_t * | value_p | ) |
Convert a BSON object into its equivalent JSON type.
| value_p | The value to convert. |
NULL upon error. | json_t* ConvertBSONToJSON | ( | const bson_t * | bson_p | ) |
Create a new JSON fragment from a given BSON one.
| bson_p | The BSON fragment to convert to JSON. |
NULL upon error. | bool InsertMongoData | ( | MongoTool * | tool_p, |
| const json_t * | values_p, | ||
| bson_t ** | reply_pp, | ||
| bson_error_t * | error_p | ||
| ) |
| bool InsertMongoDataAsBSON | ( | MongoTool * | tool_p, |
| const bson_t * | doc_p, | ||
| bson_t ** | reply_pp, | ||
| bson_error_t * | error_p | ||
| ) |
| bool RunMongoCommand | ( | MongoTool * | tool_p, |
| bson_t * | command_p, | ||
| bson_t ** | reply_pp | ||
| ) |
| bool RemoveMongoDocumentsByBSON | ( | MongoTool * | tool_p, |
| const bson_t * | selector_p, | ||
| const bool | remove_first_match_only_flag | ||
| ) |
| bson_t* ConvertJSONToBSON | ( | const json_t * | json_p | ) |
Create a new BSON fragment from a given JSON one.
| json_p | The JSON fragment to convert to BSON. |
NULL upon error. | char* GetBSONOidAsString | ( | const bson_oid_t * | id_p | ) |
| void FreeBSONOidString | ( | char * | id_s | ) |
| bson_oid_t* GetBSONOidFromString | ( | const char * | id_s | ) |
| bool SaveMongoData | ( | MongoTool * | mongo_p, |
| const json_t * | data_to_save_p, | ||
| const char * | collection_s, | ||
| bson_t * | selector_p | ||
| ) |
| bool SaveMongoDataWithTimestamp | ( | MongoTool * | mongo_p, |
| json_t * | data_to_save_p, | ||
| const char * | collection_s, | ||
| bson_t * | selector_p, | ||
| const char * | timestamp_key_s | ||
| ) |
| bool SaveAndBackupMongoDataWithTimestamp | ( | MongoTool * | mongo_p, |
| json_t * | data_to_save_p, | ||
| const char * | collection_s, | ||
| const char * | backup_collection_s, | ||
| const char * | id_key_s, | ||
| bson_t * | selector_p, | ||
| const char * | timestamp_key_s | ||
| ) |
| bool SaveMongoDataFromBSON | ( | MongoTool * | mongo_p, |
| const bson_t * | data_to_save_p, | ||
| const char * | collection_s, | ||
| bson_t * | selector_p | ||
| ) |
| bool SaveAndBackupMongoData | ( | MongoTool * | mongo_p, |
| const json_t * | data_to_save_p, | ||
| const char * | collection_s, | ||
| const char * | backup_collection_s, | ||
| const char * | id_key_s, | ||
| bson_t * | selector_p | ||
| ) |
| bool SaveAndBackupMongoDataFromBSON | ( | MongoTool * | mongo_p, |
| const bson_t * | data_to_save_p, | ||
| const char * | collection_s, | ||
| const char * | backup_collection_s, | ||
| const char * | id_key_s, | ||
| bson_t * | selector_p | ||
| ) |
| bool SetMongoDataAsBSON | ( | MongoTool * | tool_p, |
| bson_t * | selector_p, | ||
| const bson_t * | doc_p, | ||
| bson_t ** | reply_pp | ||
| ) |
| bool UnsetMongoDataAsBSON | ( | MongoTool * | tool_p, |
| bson_t * | selector_p, | ||
| const bson_t * | doc_p, | ||
| bson_t ** | reply_pp | ||
| ) |
| bool UpdateMongoDataAsBSON | ( | MongoTool * | tool_p, |
| const char *const | update_s, | ||
| bson_t * | selector_p, | ||
| const bson_t * | doc_p, | ||
| bson_t ** | reply_pp | ||
| ) |
| bool SetMongoDataAsBSONForGivenId | ( | MongoTool * | tool_p, |
| bson_oid_t * | id_p, | ||
| bson_t * | update_p, | ||
| bson_t ** | reply_pp | ||
| ) |
| bool SetMongoData | ( | MongoTool * | tool_p, |
| bson_t * | selector_p, | ||
| const json_t * | values_p, | ||
| bson_t ** | reply_pp | ||
| ) |
| bson_oid_t* GetNewBSONOid | ( | void | ) |
| bson_oid_t* GetNewUnitialisedBSONOid | ( | void | ) |
| bson_oid_t* CopyBSONOid | ( | const bson_oid_t * | src_p | ) |
| void FreeBSONOid | ( | bson_oid_t * | id_p | ) |
| bson_t* AllocateBSON | ( | void | ) |
| void FreeBSON | ( | bson_t * | bson_p | ) |
| bool GetMongoIdFromJSON | ( | const json_t * | data_p, |
| bson_oid_t * | id_p | ||
| ) |
| bool GetNamedIdFromJSON | ( | const json_t * | data_p, |
| const char *const | key_s, | ||
| bson_oid_t * | id_p | ||
| ) |
| const char* GetNamedIdAsStringFromJSON | ( | const json_t * | data_p, |
| const char *const | key_s | ||
| ) |
| bool GetIdFromJSONKeyValuePair | ( | const json_t * | id_val_p, |
| bson_oid_t * | id_p | ||
| ) |
| bool AddCompoundIdToJSON | ( | json_t * | data_p, |
| bson_oid_t * | id_p | ||
| ) |
| bool AddNamedCompoundIdToJSON | ( | json_t * | data_p, |
| bson_oid_t * | id_p, | ||
| const char * | key_s | ||
| ) |
| bool AddCompoundIdToJSONArray | ( | json_t * | array_p, |
| const bson_oid_t * | id_p | ||
| ) |
| bool AddIdToJSON | ( | json_t * | data_p, |
| bson_oid_t * | id_p, | ||
| const char * | key_s | ||
| ) |
| bool AddQueryTerm | ( | bson_t * | query_p, |
| const char * | key_s, | ||
| const char * | value_s, | ||
| bool | regex_flag | ||
| ) |
| int64 GetNumberOfMongoResults | ( | MongoTool * | tool_p, |
| bson_t * | query_p, | ||
| bson_t * | extra_opts_p | ||
| ) |
| OperationStatus ProcessMongoResults | ( | MongoTool * | tool_p, |
| bson_t * | query_p, | ||
| bson_t * | extra_opts_p, | ||
| bool(*)(const bson_t *document_p, void *data_p) | process_bson_fn, | ||
| void * | data_p | ||
| ) |
| const char* MONGO_OID_KEY_S = "$oid" |
| const char* MONGO_TIMESTAMP_S = "modified" |
The key for specifying the timestamp of a saved piece of data.