Mongo has no way to map documents using regex to key names.
However, you can do this with $where , which allows you to use JavaScript execution to select each document. The disadvantage of $where is that it cannot take advantage of indexes, which is why it requires deserializing each document in the collection, which can be too slow for most applications.
Another way to do this in Mongo is with $exists and $or , but this requires explicit key names.
Such a scheme will be more efficient for this type of request, and also simplifies slicing on the server with $ :
{ dataFields: [ { id: 'A000', value: 'whatevs' }, { id: 'A001', value: 'whatevs' }, { id: 'A002', value: 'whatevs' }, { id: 'B000', value: 'whatevs' }, { id: 'B001', value: 'whatevs' }, { id: 'C000', value: 'whatevs' }, ] }
or
{ dataFields: [ { lettter: 'A', number: 0, value: 'whatevs' }, { lettter: 'A', number: 1, value: 'whatevs' }, { lettter: 'A', number: 2, value: 'whatevs' }, { lettter: 'B', number: 0, value: 'whatevs' }, { lettter: 'B', number: 1, value: 'whatevs' }, { lettter: 'C', number: 0, value: 'whatevs' }, ] }