title: before.insert / Meteor extension / mongoObservable / get last object from mongoDB = "undefined"
body: <p>I have this code extension of insert method in problems.collection.ts. I need find last inserted object, get lastId and increase it.</p>
  
  <p>Every object has own unique ID, but I want create in every object "problemSecondId" that will be more suitable and will be presented to user in my app. </p>
  
  <p>So when I create first "Problem" in collection, I get console.log "undefined" in variable "lastProblem" and object is created with "problemSecondId: 1". When I create second "Problem", I get again "undefined" and second "Problem" is created with "problemSecondId: 1" too!!! I tried a lot of things. </p>
  
  <p>Code behaves, that the query "findOne" returns "undefined" so I think, that mistake is in query, or possible mistake can be that collection "Problems" is not Mongo.Collection but MongoObservable.Collection... ? Can somebody help me?  thnx.</p>
  
  <pre><code>import { MongoObservable } from "meteor-rxjs";
  import { Problem } from "../models/problem.model";
  import { Observable } from "rxjs";
  import { Mongo } from "meteor/mongo";
  
  
  class ProblemCollection extends Mongo.Collection {
      insert(problem, callback) {
        if (!problem.problemSecondId) {
          let lastProblem = Problems.findOne({}, { sort: { problemSecondId: -1 }});
          console.log(lastProblem);
          if (lastProblem){
            let lastProblemId = lastProblem.problemSecondId++;
            problem.problemSecondId = lastProblemId;
          } else {
            problem.problemSecondId = 1;
          }
  
        }
  
        return super.insert(problem, callback);
      }
    }
  
  
  
  let problems = new ProblemCollection("problems");
  
  export const Problems = new MongoObservable.Collection&lt;Problem&gt;(problems);
  
  
  function loggedIn() {
      return !!Meteor.user();
    }
  
  Problems.allow({
      insert: loggedIn,
      update: loggedIn,
      remove: loggedIn
  });
  </code></pre>