On this note: I have this blog post let’s say (with mongodb connection):

db.define_table('blog',

                Field('author', 'string', requires = IS_NOT_EMPTY()),

                Field('date', 'datetime', default = request.now),

                Field('text', 'text'))

 

I can do: print db().select(db.blog.author) -> This will give me all the 
author in the post

I can also use mongodb api to interchangeably:

import pymongo

from pymongo import MongoClient

client = MongoClient()

client = MongoClient('localhost', 27017)

db1    = client.foo #lets say foo is my database name

db1.blog.find_one() #here blog is my collection and I want the first 
document

Out[3]: 

{u'_id': ObjectId('55498fe02514971894c70538'),

 u'author': u'Ron',

 u'date': datetime.datetime(2015, 5, 5, 23, 51, 48),
 
 u'text': u'This is my question'}
 
Question: is there an equivalent 

db().select(db.blog.author) in pymongo api? For example if I use the above 
implementation in pymongo:

db1.blog.author (wouldn’t work). But I can get specific author 
db1.blog.find({‘author’:’Ron’}) That is also equivalent to:

db(db.blog.author == ‘Ron’).select()

So, there is two way to go about it. I know some of pymongo syntax wouldn't 
apply to DAL as there are no sql equivalent to it. How is it the other way 
around?

On Saturday, May 9, 2015 at 6:27:28 AM UTC-4, Alan Etkin wrote:
>
>
> I'm bringing to the list some new user's questions
>
> It will b nice to document all the DAL syntax n equivalent pymongo api.
>
>
> Not sure what he meant, but documenting the pymongo api makes little sense 
> (it is already documented by the authors). IMO we should instead document 
> the way of accessing the adapter connection to use the pymongo api commands 
> or any adapter (maybe it is already documented).
>  
>
>> N all the DAL doesnt apply to pymongo n added pymongo features.  Just 
>> saying:)
>>
>
> DAL only uses pymongo features required by the DAL api itself, but there's 
> no equivalent command between the lower level api and DAL.
> mongodb adapter is not meant to include or extend pymongo api commands, it 
> is a high level interface for mongodb databases in web2py apps
>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to