Skip to content

Commit

Permalink
First steps for mongo like syncdb
Browse files Browse the repository at this point in the history
  • Loading branch information
flaper87 committed Apr 21, 2010
1 parent ad11a80 commit c419d90
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mongodj/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def table_names(self):
"""
Show defined models
"""
return self.django_table_names()
return self.connection.db_connection.collection_names()

def sequence_list(self):
# TODO: check if it's necessary to implement that
Expand Down
15 changes: 14 additions & 1 deletion mongodj/creation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pymongo.collection import Collection
from django.db.backends.creation import BaseDatabaseCreation

TEST_DATABASE_PREFIX = 'test_'
Expand Down Expand Up @@ -34,6 +35,18 @@ class DatabaseCreation(BaseDatabaseCreation):
}


def sql_create_model(self, model, style, known_models=set()):
opts = model._meta
kwargs = {}
if hasattr(opts, "capped_collection") and opts.capped_collection:
kwargs["capped"] = True
if hasattr(opts, "collection_max") and opts.collection_max:
kwargs["max"] = opts.collection_max
if hasattr(opts, "collection_size") and opts.collection_size:
kwargs["size"] = opts.collection_size
col = Collection(self.connection.db_connection.db, opts.db_table, **kwargs)
return "", {}

def set_autocommit(self):
"Make sure a connection is in autocommit mode."
pass
Expand Down Expand Up @@ -83,4 +96,4 @@ def destroy_test_db(self, old_database_name, verbosity=1):

def _drop_database(self, database_name):
self.connection.db_connection.conn.drop_database(database_name)


0 comments on commit c419d90

Please sign in to comment.