Skip to content

Commit

Permalink
Added support for DATE fields in mongodb raw queries - date fields wi…
Browse files Browse the repository at this point in the history
…ll be returned as UNIX timestamp

(cherry picked from commit 8302fc8)
  • Loading branch information
vladpaiu committed Feb 10, 2015
1 parent 2e6323e commit 9868043
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/cachedb_mongodb/cachedb_mongodb_json.c
Expand Up @@ -248,6 +248,14 @@ void bson_to_json_generic(struct json_object *obj,bson_iterator *it,int type)
else if (type == BSON_ARRAY)
json_object_array_add(obj,json_object_new_int((int)bson_iterator_bool(it)));
break;
case BSON_DATE:
LM_DBG("Found key %s with type date\n",curr_key);
if (type == BSON_OBJECT)
json_object_object_add(obj,curr_key,
json_object_new_int((int)(bson_iterator_date(it)/1000)));
else if (type == BSON_ARRAY)
json_object_array_add(obj,json_object_new_int((int)(bson_iterator_date(it)/1000)));
break;
case BSON_ARRAY:
LM_DBG("Found key %s with type array\n",curr_key);
obj2 = json_object_new_array();
Expand Down

0 comments on commit 9868043

Please sign in to comment.