Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoID Data Type for TEXT

Whats the best option to use for MongoID data type for the regular MongoDB TEXT data type.

Wondering why MongoID doesnt have a data type TEXT.

is it okay to use STRING type and store large amounts of data.

P.S coming from SQL background.

like image 751
Harsha M V Avatar asked Feb 03 '14 10:02

Harsha M V


People also ask

How do I use text in MongoDB?

$text OperatorUse the $text query operator to perform text searches on a collection with a text index. $text will tokenize the search string using whitespace and most punctuation as delimiters, and perform a logical OR of all such tokens in the search string.

Is document a data type?

The document database definedA document database is a type of nonrelational database that is designed to store and query data as JSON-like documents. Document databases make it easier for developers to store and query data in a database by using the same document-model format they use in their application code.

What is string in MongoDB?

MongoDB connection string is defined as connection format to join the MongoDB database server, we have using username, hostname, password, and port parameter to connect the database server. Without a connection string, we cannot connect to the database server, we need a connection string to connect the database server.


2 Answers

According to the mongoid documentation all fields are strings, unless we explicitly specify an other data types. Unlike SQL's varchar and text differences, strings in mongo have no limitation (the only limitation is that of the 16MB maximum document size) so there is no need to worry about size.

like image 134
xlembouras Avatar answered Oct 07 '22 15:10

xlembouras


Yes, strings in MongoDB have unlimited length (up to document max size, of course (16MB)). So there was no reason to introduce separate TEXT column type, as do relational DBs.

Just use string type.

like image 21
Sergio Tulentsev Avatar answered Oct 07 '22 15:10

Sergio Tulentsev