MongoDB 'document' or 'dict' filetype

141 views
Skip to first unread message

Francisco Costa

unread,
May 21, 2012, 5:55:01 AM5/21/12
to web...@googlegroups.com
At the moment MongodbAdapter only has these filetypes

class MongoDBAdapter(NoSQLAdapter):
    uploads_in_blob = True

    types = {
                'boolean': bool,
                'string': str,
                'text': str,
                'password': str,
                'blob': str,
                'upload': str,
                'integer': long,
                'bigint': long,
                'float': float,
                'double': float,
                'date': datetime.date,
                'time': datetime.time,
                'datetime': datetime.datetime,
                'id': long,
                'reference': long,
                'list:string': list,
                'list:integer': list,
                'list:reference': list,
        }


Which means that if you want to insert or manage this:

{
    "field1": "super",
    "field2": 300,
    "field3": ["one", "two", "three"],
    "field4" = {foo: "bar", michael: "jordan"}
}

You can't do it for field4

Most MongoDB Collections do make use of document/dict datatype so this should be possible!

Massimo Di Pierro

unread,
May 21, 2012, 10:58:39 AM5/21/12
to web...@googlegroups.com
I think if that is what you want to do, you go beyond the scope of the dal and perhaps you should use the mongodb api instead of the dal. Perhaps we should discuss it on web2py developers. Anyway, feel free to open a ticket about this.

Alan Etkin

unread,
Jan 17, 2013, 8:25:33 PM1/17/13
to web...@googlegroups.com
At the moment MongodbAdapter only has these filetypes

The MongoDBAdapter now supports storing JSON documents, plus a json widget and IS_JSON validator. See this slice for more details:
http://www.web2pyslices.com/slice/show/1580/save-the-earth-from-a-total-data-mess-with-mongodbadapter

Reply all
Reply to author
Forward
0 new messages