title: Post TypeScript Object without '_id' field?
body: <p>I use Express, Mongoose and Angular 2 (TypeScript) making an web app. Now I want to post a <code>MyClass</code> Instance without any <code>_id</code> field.</p>
  
  <p>In mongoose we could use <code>_id</code> to do a lot of operations on mongoDB, so here is what I have done on the server side using <code>mongoose</code></p>
  
  <pre><code>  router.post('/', function(req, res, next) {
    Package.create(req.body, function (err, post) {
      if (err) return next(err);
          res.json(post);
    });
  });
  
  
  /* GET /package/id */
  router.get('/:id', function(req, res, next) {
    Package.findById(req.params.id, function (err, post) {
      if (err) return next(err);
      res.json(post);
    });
  });
  
  /* PUT /package/:id */
  router.put('/:id', function(req, res, next) {
    Package.findByIdAndUpdate(req.params.id, req.body, function (err, post, after) {
      if (err) return next(err);
  
      res.json(post);
    });
  });
  </code></pre>
  
  <p>To contain the field <code>_id</code> I created a ts Class like this:</p>
  
  <pre><code>export class Package{
  
  
      constructor(
          public guid: string,
          ...
          [other fields]
          ...
          public _id: string
      ){}
  
  }
  </code></pre>
  
  <p>Please note the <code>_id</code> at the end.</p>
  
  <p>In my angular 2 service I am doing this to post the json object to server</p>
  
  <pre><code>//create new pakcage
      private post(pck: Package): Promise&lt;Package&gt; {
          let headers = new Headers({
              'Content-Type': 'application/json'
          });
  
          return this.http
              .post(this.packageUrl, JSON.stringify(pck), { headers: headers })
              .toPromise()
              .then(res =&gt; res.json())
              .catch(this.handleError);
  
      }
  </code></pre>
  
  <p>Then I received an error as shown in the screenshot below:</p>
  
  <p><a href="https://i.stack.imgur.com/r6Mp3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r6Mp3.png" alt="enter image description here"></a></p>
  
  <p>In which it indicates that the object I post back got a empty <code>_id</code> field.</p>
  
  <p>How do I post a ts class without the <code>_id</code> field or should I do it totally differently?</p>