use of net.ravendb.client.Constants.Documents.Metadata.COLLECTION in project jnosql-diana-driver by eclipse.
the class RavenDBDocumentCollectionManager method insert.
private void insert(DocumentEntity entity, LocalDateTime time, IDocumentSession session) {
String collection = entity.getName();
Map<String, Object> entityMap = EntityConverter.getMap(entity);
String id = entity.find(EntityConverter.ID_FIELD).map(d -> d.get(String.class)).orElse(collection + '/');
session.store(entityMap, id);
IMetadataDictionary metadata = session.advanced().getMetadataFor(entityMap);
metadata.put(COLLECTION, collection);
if (Objects.nonNull(time)) {
metadata.put(EXPIRES, time.toString());
}
session.saveChanges();
entity.add(EntityConverter.ID_FIELD, session.advanced().getDocumentId(entityMap));
}
Aggregations