[Solved] Problem on `Mongo Extends: Insert` unknown `document`


#1

I try to use Mongo Extends

import { Mongo } from 'meteor/mongo'
import Schema from './schema'

class AppCollection extends Mongo.Collection {
  insert(document, callback) {
    document.testedBy = 'Theara'
    console.log(document) // undefined

    return super.insert(document, callback)
  }
}

const Categories = new AppCollection('bg_categories')
Categories.attachSchema(Schema)

export default Categories

Get undefined, when tried to insert doc


#2

Can you post the code where you call insert? Are you passing it a complete object?


#3

Now it work fine :blush:


#4

Sorry but now I have some problem with Meteor.userId() and SimpleSchema (don’t have timestamp field)

document.createdBy = Meteor.userId() // don't work