Convert String to Int on AWS DocumentDB

Viewed 702

I am currently trying to write a metabase question off AWS Document DB and I am running into an issue where I need to convert a string to an integer. Unfortunately, it seems like aws documentdb does not support $toInt and I am not sure how to get around it. Here is the query:

[
    {"$match": { 
        "metaData.fileSize" : {"$exists": true}
    }},
    {"$project": { 
        "file_size" : "$metaData.fileSize",
        "timestamp": 1,
        "past7Days": 
        { "$subtract": 
                [ ISODate(), 604800000]
        }
    }},
    {"$project": { 
        "file_size" : 1,
        "timestamp": 1,
        "dayofweek": {"$dayOfWeek":["$timestamp"]},
        "past7DaysComp": 
        { "$subtract": 
                [ "$timestamp", "$past7Days"]
        }
    }},
    {"$group" : 
            {   
                "_id" : {"dayofweek" : "$dayofweek"},
                "size": {"$avg" : "$file_size"}
            }
    }
]

The group returns nothing for size since it is not of a numeric type. Any ideas how to convert file_size to integer or double or float?

0 Answers
Related