Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection functions not working on astronomy objects #664

Open
lensKamdem opened this issue Mar 14, 2018 · 6 comments
Open

Collection functions not working on astronomy objects #664

lensKamdem opened this issue Mar 14, 2018 · 6 comments

Comments

@lensKamdem
Copy link

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

@lukejagodzinski
Copy link
Member

@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.

@lensKamdem
Copy link
Author

@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?

@lukejagodzinski
Copy link
Member

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
});

@lensKamdem
Copy link
Author

@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!

@lukejagodzinski
Copy link
Member

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

@lensKamdem
Copy link
Author

I will try it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants