File: utils.py

package info (click to toggle)
python-mongomock 4.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,028 kB
  • sloc: python: 16,412; makefile: 24
file content (12 lines) | stat: -rw-r--r-- 343 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
class DBRef(object):

    def __init__(self, collection, id, database=None):
        self.collection = collection
        self.id = id
        self.database = database

    def as_doc(self):
        doc = {'$ref': self.collection, '$id': self.id}
        if self.database is not None:
            doc['$db'] = self.database
        return doc