Closed smaheshs closed 5 years ago
Hi @smaheshs
A quick read of the source shows a Collection
has a pointer to the Database
:
type Collection struct {
Database *Database
Name string // "collection"
FullName string // "db.collection"
}
The Database
contains a pointer to the Session
:
type Database struct {
Session *Session
Name string
}
And none of the other information would be invalidated by a session.Refresh()
.
Hope that helps! Dom
From this discussion here I understand that when a session is being used in a for loop it is safe to do a
session.Refresh()
at the beginning of the loop.However it is not clear how to handle the collections created from the session.
Should the collection variables be assigned after every Refresh() like this:
OR can the collection be assigned only once outside the loop as below:
It would be helpful if this information is available in the documentation.
What version of MongoDB are you using (
mongod --version
)?What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
Unfortunately this is a rare issue due to which the right approach cannot be arrived at easily just by experimenting.
Can you reproduce the issue on the latest
development
branch?