navid_gh
navid_gh

Reputation: 1883

Using repository in Mongobee migration

I'm using the latest version of jhipster up to now ( 3.6.1 ) and it's using MongoBee for mongodb migration. I want to know about the consequences of using spring data repository or MongoTemplate in MongoBee migration class

I don't want to use DB class because I have to write my property name as string like below. So I want to use my Entity ( Document ) and using setter for that.

@ChangeSet(order = "01", author = "initiator", id = "01-addAuthorities")
public void addAuthorities(DB db) {
    DBCollection authorityCollection = db.getCollection("jhi_authority");
    authorityCollection.insert(
        BasicDBObjectBuilder.start()
            .add("_id", "ROLE_ADMIN")
            .get());
    authorityCollection.insert(
        BasicDBObjectBuilder.start()
            .add("_id", "ROLE_USER")
            .get());
}

So another question is if I use Entity for saving in db, what happens if I change property name in Entity after the changeset applied?

@juliendubois I asked this question in your twitter and you told me to write in StackOverflow

Upvotes: 3

Views: 5347

Answers (1)

Julien Dubois
Julien Dubois

Reputation: 3688

From the MongoBee documentation this looks OK. The Spring Data repository and the MongoTemplate are just wrappers around the MongoDB API, so there shouldn't be any issue using them.

Upvotes: 1

Related Questions