コード例 #1
0
 public static void initializeDatabase(MongoOperations mongoTemplate) {
   if (!mongoTemplate.collectionExists(Rider.class)) mongoTemplate.createCollection(Rider.class);
   if (!mongoTemplate.collectionExists(Hub.class)) mongoTemplate.createCollection(Hub.class);
   if (!mongoTemplate.collectionExists(RideRequest.class))
     mongoTemplate.createCollection(RideRequest.class);
   if (!mongoTemplate.collectionExists(RideBooking.class))
     mongoTemplate.createCollection(RideBooking.class);
   mongoTemplate.indexOps(RideBooking.class).ensureIndex(new GeospatialIndex("itinerary.origin"));
   mongoTemplate
       .indexOps(RideBooking.class)
       .ensureIndex(new GeospatialIndex("itinerary.destination"));
   if (!mongoTemplate.collectionExists(RideProposal.class))
     mongoTemplate.createCollection(RideProposal.class);
   mongoTemplate.indexOps(RideProposal.class).ensureIndex(new GeospatialIndex("itinerary.origin"));
   mongoTemplate
       .indexOps(RideProposal.class)
       .ensureIndex(new GeospatialIndex("itinerary.destination"));
 }
コード例 #2
0
  @Before
  public void setUp() {

    if (!operations.collectionExists(Customer.class)) {
      operations.createCollection(Customer.class);
    }

    // just make sure we remove everything properly
    operations.getCollection("system.js").remove(new BasicDBObject());
    repository.deleteAll();
  }