First, I will show you two pictures of data recorded in MongoDB Compass.
[User Collection]
[Plan Collection]
As you can see I get only 3 values from the user in the User collection
: name
, phone
and address
. It is understood that _id
is automatically generated through ObjectID
when such information is received, but I do not know why _class
is created. When _class
contains user information that I created myself, class information for use is entered as a string value. ex) "com.example.User".
Plan collection also receives 11 data from index
to createdAt
from the user, and _id
is automatically generated through ObjectID
. But here we get __v
instead of _class
, and this value will always exist as 0.
For reference, I did not implement the way the Plan Collection is saved, but I implemented the way the User Collection is saved through Spring boot.My Repository Interface looks like this:
@Repository
public interface UserRepository extends MongoRepository<User, String> {
}
- Is the creation of
_class
a result of using MongoRepository? - Are
__v
or_class
necessary values? - How can I get rid of it if I don't need it?
- Can developers change the name themselves?