Question about data types

Hello Everybody,

My database will contain documents with document values in which the value contains both text and numbers. For example: M42 or 3rd power.

So my question is: Can I define the data type as string, or are strings not allowed to contain numbers?

Thanks in advance for your feedback.


Hi Carel,

Welcome to the community!

BSON strings are UTF-8 Strings (see These strings can contain numbers.

An easy way to test this out is to create a free cluster on Atlas and insert a document. For each field in the document, you can select what type the field should be.

Hi Lauren,

Thanks for the quick reply. I’m not a developer, but I’m in the process of preparing my data

and need to work out the fields and field types for the different documents in my database.

So it’s a relief to hear that strings can also contain numbers. I’m just starting out in the MongoDB world

and I like what I see, because I could not make it work in a relational database structure.

The possibilities of MongoDB for my situation give me the reassurance that I can continue and accommodate the different

document structures I need and still be able to retrieve what I want and how I want it.

Regards, thanks and greeting from Holland,