I have a file like this only much bigger. When I import this file I get one _id field for all the records. How would I write this so that each "dateField", "description" has an "-id" so it is an individual
document.
{
dateField: "2003,02,04", description: "Yugoslavia officially changed its name to Serbia and Montenegro.",
dateField: "2003,02,05", description: "U.S. Secretary of State Colin Powell appeared before the United Nations Security Council to present evidence that Iraq possessed proscribed weapons of mass destruction and posed an immediate danger."
}
Hi William, the above is a single JSON object that has multiple `dateField` and `description` fields. You would need to massage your file so that each line was it's own object:
{"dateField": "2003,02,04", "description": "Yugoslavia officially changed it's name to Serbia and Montenegro."}
{"dateField": "2013,02,05", "description": "U.S. Secretary of State Colin Powell appeared before the United Nations Security Council to present evidence that Iraq possessed proscribed weapons of mass destruction and posed an immediate danger."}
How would I create a new Date object when I insert into a collection? I tried the below but that did not work.
dateField: new Date(1830,07,28), description: 'revolution in France replaces Charles X with Louis Philippe.',
Doing this insert works just fine for me, but remember that in Javascript, months are 0 based (January is 0, February is 1, December is 11), so the above insert will change the date to be '1830-08-28'. Are you getting errors with your insert? If so, please let us know what they are.
Hopefully this helps you out.
Cheers!
~Doug