@Override public List<Document> bulkFetch(List<DBRef> refs) { Assert.notNull(mongoDbFactory, "Factory must not be null!"); Assert.notNull(refs, "DBRef to fetch must not be null!"); if (refs.isEmpty()) { return Collections.emptyList(); } String collection = refs.iterator().next().getCollectionName(); List<Object> ids = new ArrayList<>(refs.size()); for (DBRef ref : refs) { if (!collection.equals(ref.getCollectionName())) { throw new InvalidDataAccessApiUsageException( "DBRefs must all target the same collection for bulk fetch operation."); } ids.add(ref.getId()); } List<Document> result = getCollection(refs.iterator().next()) // .find(new Document("_id", new Document("$in", ids))) // .into(new ArrayList<>()); return ids.stream() // .flatMap(id -> documentWithId(id, result)) // .collect(Collectors.toList()); }
@Override public Document fetch(DBRef dbRef) { StringUtils.hasText(dbRef.getDatabaseName()); return getCollection(dbRef).find(Filters.eq("_id", dbRef.getId())).first(); }
@Override public List<Document> bulkFetch(List<DBRef> refs) { Assert.notNull(mongoDbFactory, "Factory must not be null!"); Assert.notNull(refs, "DBRef to fetch must not be null!"); if (refs.isEmpty()) { return Collections.emptyList(); } String collection = refs.iterator().next().getCollectionName(); List<Object> ids = new ArrayList<>(refs.size()); for (DBRef ref : refs) { if (!collection.equals(ref.getCollectionName())) { throw new InvalidDataAccessApiUsageException( "DBRefs must all target the same collection for bulk fetch operation."); } ids.add(ref.getId()); } List<Document> result = getCollection(refs.iterator().next()) // .find(new Document("_id", new Document("$in", ids))) // .into(new ArrayList<>()); return ids.stream() // .flatMap(id -> documentWithId(id, result)) // .collect(Collectors.toList()); }
@Override public Document fetch(DBRef dbRef) { StringUtils.hasText(dbRef.getDatabaseName()); return getCollection(dbRef).find(Filters.eq("_id", dbRef.getId())).first(); }