Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    shaliniloop
    @shaliniloop
    i have schema in meteor
    import { Enum } from 'meteor/jagi:astronomy';
    const Status = Enum.create({
    name: 'Status',
    identifiers: {
    New: 1,
    progress: 2,
    Complete :3
    }
    });
    status: {
    type: Status,
    defaultValue: 1,
    }
    i want to ruin update query
    run*
    var findVar = Orders.update({"_id": "w46xKnB3pFniNiwoJ"},{$set: { "status" : "3"} })
    console.log(findVar);
    }
    but it gives error
    update failed: Error: Status must be of type Enum
    can anyone help in this?
    Andreas
    @andreyunugro
    @alexpriceonline Actually, currently I use meteor as server only. So I can not sure whether helper can be used for server only. But you always able to use Meteor.isServer check. :smile:
    @shaliniloop Hi, do you still need help on this? What is your schema classname?
    Andreas
    @andreyunugro
    I usually use Enum with identifiers option using array, and this is example how I define default value:
    // Define FileStatus enum.
    const FileStatus = Enum.create({
      name: 'FileStatus',
      identifiers: ['TEMPORARY', 'PERMANENT'],
    });
    // Inside schema definition.
    status: {
        type: FileStatus,
        default: FileStatus.TEMPORARY,
    },
    Andreas
    @andreyunugro
    And this is example how to use it.
    // Import file schema and file status enum.
    import { File, FileStatus } from '/imports/classes/File.js';
    // Trying to create new file with permanent status.
    const file = new File();
    file.status = FileStatus.PERMANENT;
    file.save();
    Ly Nam
    @lyquocnam
    hello guys i try create helpers but it not show when call
      helpers: {
            children() {
                // Lấy danh sách tất cả users theo referrerId
                const children = User.find({ referrerId: this._id }).fetch()
                return children
            },
            childrenCount() {
                return this.children().count()
            }
        },
        behaviors: {
            timestamp: {
                hasCreatedField: true,
                createdFieldName: 'createdAt',
                hasUpdatedField: true,
                updatedFieldName: 'updatedAt'
            }
        }
    user .children() is children is not function
    someone please help, i really confuse with this
    Ly Nam
    @lyquocnam
    Can i create static method with astronomy ?
    Lukas Van Orshoven
    @Lukasvo
    @lyquocnam that should work. What does the rest of the code look like? Do you have a field also named children? Also, terminate your statements with semicolons, please
    On another topic: @jagi says here (jagi/meteor-astronomy#547) that an option like { modified: true } is implemented in the validate() function, but I can't find anything in the docs or the code. Is it not implemented? How could I use such a feature? It would greatly benefit the performance of my app
    Lukas Van Orshoven
    @Lukasvo
    Thank you, @andreyunugro! Too bad this isn't documented.
    Andreas West
    @a4xrbj1
    Hi guys, how do I remove a field from a collection in Astronomy? I'm currently using $unset: { temp: '' } but it seems that Astronomy is not allowing this operation to happen. I'm wondering what the equivalent is. Please that I don't want to set it to false or null, I want the field being deleted from my collection. Thanks in advance for your help!
    Andreas West
    @a4xrbj1
    Found this old thread: https://www.bountysource.com/issues/27982620-undefined-value-should-not-be-set-as-null-into-db where Lukas writes "And you can't unset a field for a single document because you want all data to be consistent" and further down he says " In Astronomy 2.0 it will be possible to unset a field but you will be doing it on your own risk :P"
    Luca Di Gaspero
    @liuq
    Hi all, I am trying to use class level validation, however the example in the documentation is not so helpful (being incorrect)
    validators: [
    firsName: [{
    type: 'minLength',
    param: 3
    }]
    ]
    I tried fixing it as
    validators: [{ type: "myCustomClassValidator" }] but i still get TypeError: ["Problem" class]["validators" property] Validators definition has to be an array of objects
    Andreas
    @andreyunugro
    @liuq You need to state your field key, for example:
    validators: [
      xxxField: [{ type: 'yourCustomClassValidator'}],
    ],
    Luca Di Gaspero
    @liuq
    Right, so it's not possible to define a real class-level validator (i.e., looking at all fields), this is just a place where to put field-level validation.
    Emad Radwan
    @EmadRadwan
    Hi There,
    Sorry for a pure beginner question. Does Astronomy provide alternative for Mongoose?
    Andrew Ckor
    @andrewckor
    No astronomy is only for meteor
    Alex Price
    @remotealex
    Is there a way to set e.trusted to false for testing purposes?
    Alex Price
    @remotealex
    Looking through the lib code it doesn't look like it... I'll override with NODE_ENV for now
    tanase-sebastian
    @tanase-sebastian
    Hello, does astronomy support the definition of relations between tables ? I see some github comments from 2015 but nothing more
    tanase-sebastian
    @tanase-sebastian
    Or should I be using methods inside the objects ?
    Lukas Van Orshoven
    @Lukasvo
    Seems like there's a package for that. I don't have any experience with it. https://jagi.github.io/meteor-astronomy/v1#relations
    tanase-sebastian
    @tanase-sebastian
    @Lukasvo but that is v1
    do you guys use v1 or v2 in production apps ?
    Lukas Van Orshoven
    @Lukasvo
    Oh, sorry 'bout that. I also read that package has been discontinued jagi/meteor-astronomy#624
    I use v2. I simply store the id of the related Class as a String and use helpers to access it
    Iain Hallam
    @iainhallam
    Is anyone using Astronomy with Grapher?
    Srimal Priyanga
    @SrimalPriyanga
    Couldn't find any rect example using astronomy, does is possible to use astronomy with react
    Ryan Watts
    @rwatts3
    Just finding out about Astronomy, Great Work !
    Is there an Autoform type companion to Astronomy.
    Such as Aldeed's Autoform is to Simpleschema ?
    siruscoder
    @siruscoder
    I am sure this is something very obvious that I am missing.... how can I programmatically get the name of the Astronomy class (for example in a helper)?
    Lukas Van Orshoven
    @Lukasvo
    Class.getName() ?
    Frank Pimenta
    @frankapimenta
    TypeError: Cannot read property 'create' of undefined -----> but I am importing
    someone?