Setting own mongoose schema _id property
<p>I've found a number of examples showing the ability to set your own <code>_id</code> property to something other than the default ObjectId in a mongoose schema:</p>

<pre><code>var personSchema = new mongoose.Schema({
    _id: Number,
    name: String
});
</code></pre>

<p>A few questions I have:</p>

<p>1) Does this auto increment and handle everything else for me? The only examples I've seen don't show any additional code to ensure this a unique and incremented key in MongoDB.</p>

<p>2) This doesn't seem work for me. When I remove the <code>_id</code> from the schema, I get documents posting correctly as expected, but when I add it (<code>_id: Number</code>), nothing gets added to the collection, and Postman returns just an empty object <code>{}</code>. Here's the relevant code:</p>

<pre><code>var personSchema = new mongoose.Schema({
    _id: Number,
    name: String
});

var Person = mongoose.model("Person", personSchema);

app.get("/person", function (req, res) {
    Person.find(function (err, people) {
        if (err) {
            res.send(err);
        } else {
            res.send(people)
        }
    });
});

app.post("/person", function(req, res) {
    var newPerson = new Person(req.body);

    newPerson.save(function(err) {
        if (err) {
            res.send(err);
        } else {
            res.send(newPerson);
        }
    });
});
</code></pre>

<p>A POST request returns <code>{}</code>, and neither the collection nor document are created.</p>