Sha256: 1d02d7739aebf7e847b8d7a31dadf5bacd3f186a7202af7cdd85fac3ae84b68c
Contents?: true
Size: 607 Bytes
Versions: 6
Compression:
Stored size: 607 Bytes
Contents
module Locomotive::Steam module Adapters module MongoDB class Command def initialize(collection, mapper) @collection = collection @mapper = mapper end def insert(entity) # make sure the entity gets a valid id entity[:_id] ||= BSON::ObjectId.new serialized_entity = @mapper.serialize(entity) @collection.insert_one(serialized_entity) entity end def delete(entity) @collection.find(_id: entity._id).delete_one if entity._id end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems