Skip to content

Commit

Permalink
Merge f43aa22 into 37365a1
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Eeo committed Jul 22, 2014
2 parents 37365a1 + f43aa22 commit dbe7131
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/test_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
def test_one_table(db):
table1 = db.table('table1')

table1.insert({'int': 1, 'char': 'a'})
table1.insert({'int': 1, 'char': 'b'})
table1.insert({'int': 1, 'char': 'c'})
docs = [{'int':1, 'char':x} for x in 'abc']
table1.insert_multiple(docs)

assert table1.get(where('int') == 1)['char'] == 'a'
assert table1.get(where('char') == 'b')['char'] == 'b'
Expand Down
9 changes: 9 additions & 0 deletions tinydb/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ def insert(self, element):

self._write(data)

def insert_multiple(self, documents):
"""
Insert multiple elements into the table.
Uses ``Table.insert``internally, so refer to the docs.
"""

for item in documents:
self.insert(item)

def remove(self, cond):
"""
Remove the element matching the condition.
Expand Down

0 comments on commit dbe7131

Please sign in to comment.