Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Jake Lacey

    I'm trying to use Astronomy together with the new grapher package https://github.com/cult-of-coders/grapher

    It's working fine so far but I'm not quite sure how to handle transformation of documents in Astronomy 2.x
    As grapher fetches the documents, I'd had to change the grapher code to use astronomies find/findOne... methods.

    What I did instead: Added a transform function to every collection.

    transform(doc) {
        const t = new MyAstroClass(doc)
        t._isNew = false
        return t

    This works fine but I'm unsure if this is a good solution. What are the reasons for Astronomy to drop Collection transforms in 2.x?
    Is it just to make it optional or to avoid side effects?

    Is it "safe" to use this kind of transform?

    Thanks in advance

    @jagi regarding Enums, is there any explanation for this: "You can also define non number ENUMs, however it’s not recommended.", other than the fact that using Strings takes more space?
    Trying to use Astronomy's Enums in an app that utilizes HTML Select elements causes difficulties, when the Enum's integer values are cast into strings. Would be convenient to use just strings all the way. Also, the data in the Mongo collection would be more self-explanatory: compare [0, 1, 2] to ['YES', 'NO', 'MAYBE']. Any thoughts?
    hi guys, thank you for a wonderful package :D
    i had one question for the more advanced users here, could i use transient fields or resolve to have, well, basically relations ? as in fetch a field from another collection into a field in the current collection?
    would that be impossible? bad? crap performance? etc?
    Bryant Biggs
    hello everyone - if I have a form split up in sections where after each section clicks "Next" or something, how can I define a schema that will allow a gradual build-up of the document? If I define the schema and the first form only fills in 4 of N inputs, the validation fails because its missing the other inputs
    @bryantbiggs 1) Keep the data stored elsewhere until the document is ready to be saved 2) Set the fields as optional, so they are not validated if they don't exist

    I just started to use astronomy when I am trying to save my folder collection am getting some error which is below

    [Exception: TypeError: Cannot read property '_id' of undefined at

    Am i missing anything in configuration ? Thank you in advance

    Bryant Biggs
    @arggh thank you for the response but I was able to resolve the issue by saving the document as the base class type for the first form submission, then on the 2nd form submission I updated the class type from the base to the child class and stored the remaining information. This kept all of the validation and required fields intact in their respective classes
    Alexis A. Banaag Jr.

    hi, have some questions with Class.findOne(). Can I add query inside the findOne() method?

    Class.create({ name: ‘Settings’, fields: { userId: String, name: String } });

    now I want to do is Class.findOne({userId: ‘hello’}); or Class.findOne({ name: ‘Hi’ }); is it possible?

    Andrew Hartwig
    Yes, but you also need a { collection: new Mongo.Collection('settings') } key in there.
    which version of regex does it support?
    I am trying to find a suitable regex expression for URLs
    Romuald DANSOU
    What about transaction with astronomy?
    Romuald DANSOU
    What about publish-composite? I am new with astronomy.
    Adalberto Soares
    You can use publishComposite with astronomy but you must use collections in it and not the classes
    I can't even get the examples running...
    on Class.create({...}) I get (STDERR) TypeError: Super expression must either be
    null or a function, not object
    any suggestions?
    using Meteor
    Figured it out. I was mistakenly putting "new" before Class.create
    Romuald DANSOU
    Thank you. Can i use babrahams:transactions with astronomy? If not how can i do transactions?
    Zak Lampert
    Is it possible to publish _removed documents explicitly?
    Lucas Peres
    how can i define my own cast method for each field ?
    need to parse date coming from input
    Hi Have a super random question... do you know if Astronomy's save field modifier accepts anything besides an array?
    I currently am testing with it and we noticed that it says array of fields but can it just accept one single string that's not in an array? Thanks! :)
    Punita Ojha
    This message was deleted
    Srimal Priyanga
    documentation not clear especially "Fetching documents" section :worried:
    In the Transient fields section, the age field is calculated and initialized in the afterInit event. In that case, will age change as time goes on, or is it calculated only once and then it's set? Why should we use Transient fields instead of Helpers in this case?
    Is there an example for integration with Ionic and typescript?
    How can I use MongoObservable (import { MongoObservable } from 'meteor-rxjs';)
    Alex Price
    Is there a nice way to prevent the updating of a field entirely? I'm extending the Meteor.users collection and want to safeguard against updating emails and passwords though the Astro class
    Alex Price
    Ah! there is an immutable flag <3
    Hi! I don't understand how to use Validators. I would like to use it to validate a method in the server side extended method, but I don't know where to put the validate method. In the class? Server-side? Client side?
    And does the validate method replace the save method? I'm a bit confused, the doc doesn't seem clear to me.
    Hi @J3m5, here the documentation link to create custom validators: https://jagi.github.io/meteor-astronomy/#creating-validators
    I recently defined it in the same file js as schema definition
    So it is server side, you can define it in the same file as schema definition, and after you defined it, you can use it in the fields definition
    AFAIK, Validate method add validation when you call .save();
    Thank you for your answer. I have succeeded to use it. For now, I don't use custom validators. I use the validate method in the server side class and i do the save() in the else of the "if(ValidationError.is(err)) {}". It works pretty well like that. It gives me this:
                    fields: ['name']
                }, (err) => {
                    if (ValidationError.is(err)) {
                        throw new Meteor.Error();
                    } else {
                        return this.save();
    Andrew Ckor
    Hello guys!
    I'm using Astronomy for a long time, it used to work perfectly. But when I updated to meteor 1.6 I keep getting errors on save();