diff options
-rwxr-xr-x | src/db.py | 13 |
1 files changed, 5 insertions, 8 deletions
@@ -27,7 +27,6 @@ class DictDB(): except couch.exceptions.NotFound: print("Creating database and indexes.") self.couchdb = self.server.create(database) - self.server.create('_users') for i in index.indexes: self.couchdb.index(i) @@ -41,7 +40,7 @@ class DictDB(): """ ts = time.time() - while ts == self._ts: + while round(ts * 1000) == self._ts: ts = time.time() self._ts = round(ts * 1000) @@ -52,17 +51,15 @@ class DictDB(): Store a document in CouchDB. """ - key = str(self.unique_key()) if type(data) is list: for item in data: - item['_id'] = key - - self.couchdb.save(item) + item['_id'] = str(self.unique_key()) + self.couchdb.save_bulk(data) else: - data['_id'] = key + data['_id'] = str(self.unique_key()) self.couchdb.save(data) - return key + return True def get(self, key): """ |