Fixed insert and upsert never resolving

Both ObjectStore.insert and ObjectStore.upsert never resolve their
promise because of an index comparison that is never true. Changing the
comparison to be between the index and the length of the data - 1
resolves the problem.