[DOCS-1268] Unable to insert via shell using the strict dates Created: 20/Mar/13  Updated: 03/Nov/17  Resolved: 16/Apr/13

Status: Closed
Project: Documentation
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: auto Assignee: Kay Kim (Inactive)
Resolution: Won't Fix Votes: 0
Labels: collector-298ba4e7
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Location: http://docs.mongodb.org/manual/reference/mongodb-extended-json/
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22
Screen Resolution: 1600 x 900
repo: docs
source: reference/mongodb-extended-json


Participants:
Days since reply: 10 years, 44 weeks, 1 day ago

 Description   

db.bug.insert(
{
"meta" : {
"dateTime" :

{ "$date" : "1970-01-01T00:00:00.000Z"}

}
})

gives failed: field names cannot start with $ [$date] at src/mongo/shell/collection.js:L147



 Comments   
Comment by Kay Kim (Inactive) [ 16/Apr/13 ]

Hi Vlad –
regarding your insert command, the datetime representation you are using is the "strict" mode and NOT the "mongo shell mode".
The REST interfaces and mongoimport/mongoexport programs support all three modes: "strict" mode, the "JavaScript" mode, and the "mongo shell" mode.
For others, you should use the appropriate driver or shell format.

Please try db.bug.insert(

{ "dateTime": new Date("04-16-2013") }

).

Hope this helps.

Regards,

Kay

Comment by Vladislav Mickevic [ 03/Apr/13 ]

We are using it not only from shell, but also from within the native JavaScript drivers.

Comment by Ed Costello [ 02/Apr/13 ]

Kay can you review the extended JSON page http://docs.mongodb.org/manual/reference/mongodb-extended-json/#gsc.tab=0 and see if clarification is needed on fields like $date (which is valid in JSON import/export but not the mongo shell)?

Comment by Ed Costello [ 02/Apr/13 ]

$date cannot be used in the shell, only in the REST interface and in the tools like mongoimport.

Comment by Vladislav Mickevic [ 27/Mar/13 ]

Any news on this? We have the same issue. Mongo v 2.2.3.

Generated at Thu Feb 08 07:40:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.