meteor-astronomy
meteor-astronomy copied to clipboard
Collection functions not working on astronomy objects
I am using astronomy v2.5.6, when use a collection function like find or update on an astronomy class instance eg. User.find(), i get the error:
TypeError: User.find() is not a function
Any clue guys? Even v2.5.3 i got the same error
@lensKamdem does the User class have the collection property provided? If not, then class will not have the find, update etc. methods as they are only intended to work on collections.
@lukejagodzinski I did not add any collection property, but in the documentation it is said that find, findOne, update etc. methods work on astronomy classes. If i need to add them myself, how do i go about?
Everything is described in docs.
import { Class } from 'meteor/jagi:astronomy';
import { Mongo } from 'meteor/mongo';
const Users = new Mongo.Collection('users');
const User = Class.create({
name: 'User',
collection: Users // YOU HAVE TO PROVIDE COLLECTION HERE
});
@lukejagodzinski i did it. When a set a property with the set() and then save it, it is normally inserted into the Mongodb collection, that is find. But when i try to use findOne or update, there is an error telling me the method is not function!
Then create reproduction repository because there is probably error in your code. You can also take a look at the example app to see how to use Astronomy https://github.com/jagi/meteor-astronomy-examples
I will try it