Skip to main content
Post Undeleted by H3AR7B3A7
added 29 characters in body
Source Link
H3AR7B3A7
  • 229
  • 2
  • 12

This is how it would look in Java:

public String getStreetNameByStreetId(String id) {
    Query streetNameByStreetId = Query.query(
            Criteria.where("_id").is(id));
    byStreetId.fields().include("name");
    return mongoTemplate.find(streetNameByStreetId, Street.class)
          .get(0).getName();
}

I realize you are looking for how this would look in Kotlin, but it should look very similar. Also, for simple CRUD operations you might want to consider just using a MongoRepository and leveraging the Domain Specific Language (DSL).

This is how it would look in Java:

public String getStreetNameByStreetId(String id) {
    Query streetNameByStreetId = Query.query(
            Criteria.where("_id").is(id));
    byStreetId.fields().include("name");
    return mongoTemplate.find(streetNameByStreetId, Street.class);
}

I realize you are looking for how this would look in Kotlin, but it should look very similar. Also, for simple CRUD operations you might want to consider just using a MongoRepository.

This is how it would look in Java:

public String getStreetNameByStreetId(String id) {
    Query streetNameByStreetId = Query.query(
            Criteria.where("_id").is(id));
    byStreetId.fields().include("name");
    return mongoTemplate.find(streetNameByStreetId, Street.class)
          .get(0).getName();
}

I realize you are looking for how this would look in Kotlin, but it should look very similar. Also, for simple CRUD operations you might want to consider just using a MongoRepository and leveraging the Domain Specific Language (DSL).

Post Deleted by H3AR7B3A7
added 4 characters in body
Source Link
H3AR7B3A7
  • 229
  • 2
  • 12

This is how it would look in Java:

public String getStreetNameByStreetId(String id) {
    Query streetNameByStreetId = Query.query(
            Criteria.where("_id").is(id));
    byStreetId.fields().include("name");
    return mongoTemplate.find(streetNameByStreetId, Street.class);
}

I realize you are looking for how this would look in Kotlin, but it should look very similar. Also, for simple CRUD operations you might want to consider just using a MongoRepositoryMongoRepository.

This is how it would look in Java:

public String getStreetNameByStreetId(String id) {
    Query streetNameByStreetId = Query.query(
            Criteria.where("_id").is(id));
    byStreetId.fields().include("name");
    return mongoTemplate.find(streetNameByStreetId, Street.class);
}

I realize you are looking for how this would look in Kotlin, but it should look very similar. Also, for simple CRUD operations you might want to consider just using a MongoRepository.

This is how it would look in Java:

public String getStreetNameByStreetId(String id) {
    Query streetNameByStreetId = Query.query(
            Criteria.where("_id").is(id));
    byStreetId.fields().include("name");
    return mongoTemplate.find(streetNameByStreetId, Street.class);
}

I realize you are looking for how this would look in Kotlin, but it should look very similar. Also, for simple CRUD operations you might want to consider just using a MongoRepository.

Source Link
H3AR7B3A7
  • 229
  • 2
  • 12

This is how it would look in Java:

public String getStreetNameByStreetId(String id) {
    Query streetNameByStreetId = Query.query(
            Criteria.where("_id").is(id));
    byStreetId.fields().include("name");
    return mongoTemplate.find(streetNameByStreetId, Street.class);
}

I realize you are looking for how this would look in Kotlin, but it should look very similar. Also, for simple CRUD operations you might want to consider just using a MongoRepository.