1602 / jugglingdb

Multi-database ORM for nodejs: redis, mongodb, mysql, sqlite3, postgresql, arango, in-memory...
http://1602.github.io/jugglingdb/
2.05k stars 241 forks source link

string vs «Schema.Text» #425

Open tonghae opened 9 years ago

tonghae commented 9 years ago

image

What's the difference between them (i use jugglingdb with redis)? And which types can be used besides string, number, date and bool? Thanks

cking commented 9 years ago

Regarding your first question:

I don't know about redis, but SQL has two different data types to store texts, either as String (e.g. VARCHAR), which store a limited amount of data (usually up to 1024) and as Texts (e.g. TEXT), which store an unlimited amount of data. Also TEXT-fields are mostly FULLTEXT-search able, instead of VARCHAR.

So, use String for short texts, like passwords, emails or similiar (strings that can be indexed as a whole), and Schema.Text for long texts, which may be fulltext-searched, e.g. blog postings.

Regarding your second question: https://github.com/1602/jugglingdb/blob/master/lib/model.js#L18 These are the default types, but adapters may create their own types. Just look through your adapters code, to see if they store custom types.