DB.write

Sublmits a BatchWrite to the DB.

Used to do batch writes.

class DB
void
write
(
const(WriteBatch) batch
,
const(WriteOptions) opt = DefaultWriteOptions
)

Throws

LeveldbException

Examples

1 auto opt = new Options;
2 opt.create_if_missing = true;
3 auto db = new DB(opt, "/my/db/");
4 // Unsafe banking example
5 auto batch = new WriteBatch;
6 
7 double joe = db.get_slice(Slice("Joe")).as!double;
8 double sally = db.get_slice(Slice("Sally")).as!double;
9 
10 joe -= 10.00;
11 sally += 10.00;
12 if(joe < 0.0)
13    joe -= 30.00; // overdraft fee
14 
15 // submit the put in a single update
16 batch.put(Slice("Joe"), Slice(joe));
17 batch.put(Slice("Sally"), Slice(sally));
18 db.write(batch);

Meta