how to store zero leading numbers in mongoDB

user4099047

I want to store numbers like 09876 in mongoDb

I'm using php driver and so far I was casting my numbers to (int) , but I just noticed the numbers which starts with Zero , not saving in mongo properly and the zero drops !

So my numbers in mongo are like : NumberLong(9876) but it must be : NumberLong(09876)

So I know I can cast my numbers to String and save them exactly as they are , but is there a way beside this ?

I mean , I dont want to store numbers as Strings in mongo db

something like casting to char ???

Zero

Numbers are stored as values and any leading zeroes will ALWAYS be dropped in numeric fields. You have 2 options:

  1. Store it as text.
  2. Format it before displaying to add the zeroes.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Truncate leading zero instantly

분류에서Dev

How to keep leading zeros by transforming array to single numbers

분류에서Dev

test with arithmetic expansion (leading zero)

분류에서Dev

How can I zero-pad numbers in a Batch FOR loop?

분류에서Dev

How does C store negative numbers in signed vs unsigned integers?

분류에서Dev

Using an array, how do I store and display the unique numbers?

분류에서Dev

How can i store 2 numbers in a 1 byte char?

분류에서Dev

How to store non utf-8 strings in mongodb using pymongo

분류에서Dev

How do you query a MongoDB document where an array attribute is null or of zero length?

분류에서Dev

Remove non-word characters and leading numbers from string

분류에서Dev

WorksheetFunction.Sum returning zero for numbers

분류에서Dev

Create list of numbers mirrored around zero (python)

분류에서Dev

Store MongoDB collection on a different drive

분류에서Dev

Retrieve MongoDB data and store it in a list

분류에서Dev

How to add leading spaces to output column

분류에서Dev

mongodb $ sum only postive Numbers

분류에서Dev

How to zero a dynamic array?

분류에서Dev

How to compare signal to zero in vhdl?

분류에서Dev

How to zero a disk + verify it afterward?

분류에서Dev

How do I preserve leading whitespaces with echo on a shell script?

분류에서Dev

How to replace non-zero elements randomly with zero?

분류에서Dev

How to store a password?

분류에서Dev

How To store a stack in onSaveInstanceState()?

분류에서Dev

How to aggregate store calls

분류에서Dev

I can only store numbers in the database, a simple shoutbox in php

분류에서Dev

How to compare numbers in bash?

분류에서Dev

How does ruby handle zero division?

분류에서Dev

how to keep zero at last without using sort

분류에서Dev

How to catch a divide by zero error in Haskell?

Related 관련 기사

뜨겁다태그

보관