Re: [go-nuts] SetSafe default value in mgo session

2016-08-05 Thread Debraj Manna
Yeah I already asked it in mgo-users forum
. I  did
not get any response from there. So asked it in this forum as I saw quite a
few mgo related discussion in golang-nuts

.

On Fri, Aug 5, 2016 at 1:58 PM, Kiki Sugiaman  wrote:

> Then the answer to your question is the answer to the following question:
>
> Is there a difference between not calling getLastError at all and calling
> getLastError(0, 0)?
>
> It's now a mongodb question and not a Go question anymore. Feel free to
> ask that of course. But if you're not getting the answer you want, that's
> because this mailing list is the wrong place to ask.
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/to
> pic/golang-nuts/Mdc4ntGIvwE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] SetSafe default value in mgo session

2016-08-05 Thread Kiki Sugiaman

Then the answer to your question is the answer to the following question:

Is there a difference between not calling getLastError at all and 
calling getLastError(0, 0)?


It's now a mongodb question and not a Go question anymore. Feel free to 
ask that of course. But if you're not getting the answer you want, 
that's because this mailing list is the wrong place to ask.


--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] SetSafe default value in mgo session

2016-08-05 Thread Serhat Şevki Dinçer
There is the difference of (not) calling 
https://docs.mongodb.com/v3.0/reference/method/db.getLastError/

This is possibly a better place to ask this:
https://groups.google.com/forum/m/#!forum/mgo-users

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] SetSafe default value in mgo session

2016-08-04 Thread Debraj Manna
I know this. I am asking about the functionality of the mgo driver while
calling SetSafe(nil) & SetSafe(&Safe{})? How mgo will behave in both the
cases while doing a write to Mongo?

On Fri, Aug 5, 2016 at 11:09 AM, Kiki Sugiaman  wrote:

> &Safe{} gives you a pointer to a new instance of Safe with zero value for
> all its fields.
>
> https://tour.golang.org/basics/12
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/to
> pic/golang-nuts/Mdc4ntGIvwE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] SetSafe default value in mgo session

2016-08-04 Thread Kiki Sugiaman
&Safe{} gives you a pointer to a new instance of Safe with zero value 
for all its fields.


https://tour.golang.org/basics/12

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] SetSafe default value in mgo session

2016-08-04 Thread Debraj Manna
Can someone help me in clearing my doubts?

On Aug 4, 2016 4:36 PM, "DM"  wrote:

> Can someone explain me the difference between the default value of
> SetSafe() which is &Safe{}and SetSafe(nil)?
>
> As per the mgo godoc :-
>
> If the safe parameter is nil, the session is put in unsafe mode, and writes 
> become fire-and-forget, without error checking. The unsafe mode is faster 
> since operations won't hold on waiting for a confirmation.
>
> If the safe parameter is not nil, any changing query (insert, update, ...) 
> will be followed by a getLastError command with the specified parameters, to 
> ensure the request was correctly processed.
>
> The default is &Safe{}, meaning check for errors and use the default behavior 
> for all fields.
>
> Looking at the code
>  it
> seems it will call getLastError with values j:false, w:0, wtimeout:0.
> This means it will not return any error from mongo and the behavior seems
> to be similar while calling SetSafe(nil).
>
> Then what error I am expected to receive while calling mongo with
> SetSafe(&Safe{})?
>
> I am on Mongo 3.0.9.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/Mdc4ntGIvwE/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] SetSafe default value in mgo session

2016-08-04 Thread DM


Can someone explain me the difference between the default value of SetSafe() 
which 
is &Safe{}and SetSafe(nil)? 

As per the mgo godoc :-

If the safe parameter is nil, the session is put in unsafe mode, and writes 
become fire-and-forget, without error checking. The unsafe mode is faster since 
operations won't hold on waiting for a confirmation.

If the safe parameter is not nil, any changing query (insert, update, ...) will 
be followed by a getLastError command with the specified parameters, to ensure 
the request was correctly processed.

The default is &Safe{}, meaning check for errors and use the default behavior 
for all fields.

Looking at the code 
 it 
seems it will call getLastError with values j:false, w:0, wtimeout:0. This 
means it will not return any error from mongo and the behavior seems to be 
similar while calling SetSafe(nil).

Then what error I am expected to receive while calling mongo with 
SetSafe(&Safe{})?

I am on Mongo 3.0.9.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.