I had some thought about that too.
We could implement this in a general way like the list is done.
The only side effect is that we would have to implement the datatype on all stores.
And then implement the dynamic subdocument for couchdb and mongoDB?
Would that be an idea?
From: web2py-d...@googlegroups.com [mailto:web2py-d...@googlegroups.com] On Behalf Of Francisco Costa
Sent: Monday, May 21, 2012 6:34 PM
To: web2py-d...@googlegroups.com
Subject: [w2py-dev] MongoDB 'document' or 'dict' filetype
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!
--
mail from:GoogleGroups "web2py-developers" mailing list
make speech: web2py-d...@googlegroups.com
unsubscribe: web2py-develop...@googlegroups.com
details : http://groups.google.com/group/web2py-developers
the project: http://code.google.com/p/web2py/
official : http://www.web2py.com/
Geen virus gevonden in dit bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 2012.0.1913 / Virusdatabase: 2425/5013 - datum van uitgifte: 05/21/12
Sounds like plan, but how to search them?
Cause the advantage is that it is easy to search the subdocuments.
If this advantage is not there, then what advantage is there at all?
Indeed, so would it not be possible to create a subtable field?
Like
Db.define_temptable(‘emailadresses’,
Field(‘email’,’string’)
Field(‘emailthisadres’,’boolean’))
Db.define_table(‘person’
Field(‘name’,’string’),
Field(‘emailadresses’, db.temptable. emailadresses))
The SQL tables would just define this as a many-to-one relation and document stores could use the advantages of a sub-document.
Also the returned input would be validated.
Regards Mark,
# Better definition syntax would be like this…
Db.define_table(‘person’
Field(‘name’,’string’),
Field(‘emailadresses’,{
“table”:”emailadress”,
“fields”:[
{name=”email”,type=”string”},
{name=” emailthisadres”,type=”boolean”}
]
})
)
#Query would be like this.
Db(db.person.emailadresses[‘email’]==’em...@gmail.com’).select(db.person.emailadresses[‘emailthisadres’])
Sql => SELECT emailadresses.emailthisadres from person [JOIN emailadresses ON emailadresses.person == person.id] WHERE emailadresses.email =’em...@gmail.com’;
The result returned would be like any other join.
---
The part between brackets must be the result from db.person.emailadresses[‘emailthisadres’] in the select()
We could launch this code from the [] of the fields?
I sent one in mongoDB later, but it will be easier there since no table has to be added.
This is easy written of course and way more difficult to implement.
but not impossible in my belief.
I don’t think this is another proposal.
Since the treat starter made a strong argument for subdocuments in web2py.
This is an improved bit more risky proposal to towards his request.
Versie: 2012.0.1913 / Virusdatabase: 2425/5015 - datum van uitgifte: 05/22/12