Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8408139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:33:21+00:00 2026-06-09T23:33:21+00:00

I am querying a collection that includes an integer value among it’s values, and

  • 0

I am querying a collection that includes an integer value among it’s values, and loading resulting documents into this struct:

type Subscription struct {
    Id bson.ObjectId "_id,omitempty"
    Listen string
    Job string
    TimeoutSeconds int
    Data string
}


var subscription Subscription

subscriptions := subscriptionsCol.Find(bson.M{"listen": "example_channel"}).Iter()
for subscriptions.Next(&subscription) {
    log("Pending job: %s?%s (timeout: %d)\n",
            subscription.Job, 
            subscription.Data, 
            subscription.TimeoutSeconds)
}

This is what phpMoAdmin shows me:

[_id] => MongoId Object (
    [$id] => 502ed8d84eaead30a1351ea7
)
[job] => partus_test_job_a
[TimeoutSeconds] => 30
[listen] => partus.test
[data] => a=1&b=9

It puzzles me that subscription.TimeoutSeconds contains always 0, when I’m positive I have 30 in the document I inserted in the collection.

All other values are retrieved OK.

What’s wrong with the int type?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T23:33:22+00:00Added an answer on June 9, 2026 at 11:33 pm

    Have you tried setting the “key” value for that field?

    Unmarshal

    The lowercased field name is used as the key for each exported field,
    but this behavior may be changed using the respective field tag.

    type Subscription struct {
        Id              bson.ObjectId    "_id,omitempty"
        Listen          string
        Job             string
        TimeoutSeconds  int     "TimeoutSeconds"
        Data            string
    }
    

    The other fields are working fine because their lowercase value matches your Mongo fields in the collection, whereas TimeoutSeconds is using the TitleCase. What is happening is the int field is being left at its zero value, since the Unmarshal can’t map a field to it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

tricky mongodb querying problem: I have a collection 'Accounts' with a bunch of documents
I'm new to Sinatra and I'm trying to figure out how querying a collection
Just started mongo and started having issue with querying already. i have a collection
Querying a Nested Set Model table , here's the SQL... how can this be
I'm querying the database for a single record that matches the id passed in
i'm querying a database like this: SELECT * from Log WHERE cookieId IN (select
I'm querying an MFC implemented COM object that is implemented as follows: class CA
I am using 10Gen .net driver for MongoDB and querying objects that has empty
Is there a way of querying array fields within documents in mongodb using more
The situation I have is that I'm querying MongoDB with a string for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.