Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Joe
    @joetidee
    Is there support for atomic counters, i.e. using getNextSequence("CounterName") if the insert/update queries?
    janek
    @jbbr

    @jagi Hello, I've a question about astronomy v2.
    Is it somehow possible to synchronously validate fields on the client?

    I used to do in v1:

    var isValid = someObj.validate('someField')

    In v2 it seems to be:

    someObj.validate({fields: ['someField']}, (err) => { ... });

    As I'm using the result of .validate( in form validation, it's somewhat difficult to rewrite it for asynchronous handling.

    Is there a reason for async validation other then server side processing? Maybe a way of doing client-only validation could be added?

    janek
    @jbbr

    Hm, looked in the code and it seems as server side validation is now somehow a must. Or am I overlooking something?
    Looks like client side validation can be disabled with simulation argument, but not server validation.

    I'm not yet convinced with this approach. I don't care if e.g the length of the first name of a user is valid according to the server. I'd like a check like this to be client only to be fast and easy for client only validations e.g for forms.

    When submitting the form I do care about server-side validation - but not before. Its extra load for the server for no good reason

    The file https://github.com/jagi/meteor-astronomy/blob/v2/lib/modules/validators/utils/document_validate.js seems to have the validation code I need. But it's not exported.
    jagi
    @jagi
    @jbbr I know it may be a problem that it validates on the server by default, maybe I'm gonna have to change that behavior. But it shouldn't be hard to just use callback function anyway.
    and you should be able to catch validation errors in the following way:
    try {
      doc.validate();
    } catch(err) {}
    however it's not going to return true/false value anymore
    and I'm not gonna change that
    janek
    @jbbr
    @jagi Yes, thanks. I figured out the try/catch way also.
    Only problem: looks like I get uncaught errors for fields I don't care about when using it.

    e.g:

    try {
          myObj.validate({fields: ['someField']});
        } catch (err) {
          console.error('Got error', err);
        }

    I get Something like:

    Uncaught Error: "someOtherField" is required [validation-error]
    The error for "someField" is catched properly
    I only want to check a specific field so thats problematic in my case
    janek
    @jbbr
    do you think this is a bug or is this intended behavior? If its a bug I will gladly create an issue
    jagi
    @jagi
    @jbbr hmmm it should work propery. You may create an issue
    jhuenges
    @jhuenges
    @jagi I read the validation part of the documentation, however I am not sure how to implement an equivalent custom() function like SimpleSchema has. Is there a possibilty to do so?
    jayspirits
    @jayspirits
    my astronomy is not updating to 2.0, any thoughts?
    jagi
    @jagi
    @jhuenges you have to create custom validator http://jagi.github.io/meteor-astronomy/v2#creating-validators
    However, maybe I will introduce a validator called "custom" which as a param takes a function which has to return true/false
    @jayspirits what do you mean by saying "is not updating". Are you getting some error?
    dw72
    @dw72

    @jagi there is mistake in docs...
    "NOTICE: In the first line, we call the find() method from the User class and in the second line from the Users collection. The slug behavior uses the beforeFind event to modify selector that will cause fetching only non-removed documents."

    There is 'slug' but it should be 'softremove' behavior

    jhuenges
    @jhuenges
    @jagi is there out of the box integration for validated-method or do I have to write my own validation function?
    mytc
    @mytc
    @jagi , in version 1 I can use set() to update a document with a object. eg: space.set({title:'blah blah', content:'blah blah', category: 'blah blah'}); But in version 2, the set()is deprecated. Is there any way to set the document with an object?
    Max Matthews
    @maxmatthews
    @mytc I would think you can just do space = {title:'blah blah', content:'blah blah', category: 'blah blah'} Could be wrong about that though. Haven't pulled the trigger to v2 yet because I need the relations module
    mytc
    @mytc
    @maxmatthews , but when I try to saving the data using save() method, I got this ' has no method \'save\'\n ' in the terminal..I saving it in server side only though
    Max Matthews
    @maxmatthews
    @mytc How about space = new Space({title:'blah blah', content:'blah blah', category: 'blah blah'})
    The problem with that is it's going to overwrite fields, not update the ones you provided. Not sure if that's an issue for you
    Max Matthews
    @maxmatthews
    @mytc Where did you see that set is depreciated? According to this section of the documentation it's still valid: http://jagi.github.io/meteor-astronomy/v2#setting-and-getting-values
    @jagi Any updates on relations support for v2? Happy to lend a hand if you want some help.
    mytc
    @mytc
    @maxmatthews , I tried with set(), but then i get this 'has no method `set\'\'n' again. I think maybe the problem is on the method been called in server side. I sorely saving the object on method call, I don't know if this is the issue. However, no problem on creating new document though.
    Max Matthews
    @maxmatthews
    @mytc Can you post some code or a gist?
    mytc
    @mytc
    Note that the EditSpace in the meteor method
    Max Matthews
    @maxmatthews
    So I'm guessing is Spaces is a Mongo.Collection? I think you should be using Space as that's the astronomy class.
    ragulka
    @ragulka
    has anybody had success in defining a User class using the Meteor.users collection?
    I'm having trouble with it - whenever I do User.findOne() in client, I get undefined as the result
    Tsegaselassie Tadesse
    @tsega
    @ragulka, how have you defined your User astronomy class here is how I do it:
    User = Astro.Class({
        name: 'User',
        collection: Meteor.users,
        fields: {
            ...
        },
        validators: {
            ...
        },
        methods: {
            ...
    });
    Then, of course, you need to publish Meteor.users from the server and subscribe to it on the client. There is no need to define a new Users collection! You can work with the Meteor.users one it will be giving you the newly defined User Astro class.
    mytc
    @mytc

    @maxmatthews , you were right, it is my mistake. Changing to astronomy class works. However, I still got this exception in the console.

    Exception while invoking method 'EditSpace' { stack: 'TypeError: Cannot read property \'upsert\' of undefined\n at MongoConnection.mongoConnectionProto.(anonymous function) [as update] (packages/meteorhackskadira/lib/hijack/db.js:73:1)\n at OptimizedApply (packages/meteorhacks_kadira/lib/utils.js:31:1)\n at Object.ret.(anonymous function) [as update] (packages/meteorhacks_kadira/lib/hijack/db.js:20:1)\n at documentUpdate (packages/jagi:astronomy/lib/modules/storage/utils/document_update.js:75:41)\n at Class.save (packages/jagi:astronomy/lib/modules/storage/class_prototype_methods/save.js:106:50)\n at [object Object].EditSpace (apps/booking/server/actions.js:49:12)\n at [object Object].methodMap.(anonymous function) (packages/meteorhacks_kadira/lib/hijack/wrap_session.js:164:1)\n at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1704:12)\n at packages/ddp-server/livedata_server.js:711:19\n at [object Object]..extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)',

    mytc
    @mytc
    But the document properly updated though
    Max Matthews
    @maxmatthews
    Hmm, got no ideas on that one
    mytc
    @mytc
    @maxmatthews , hmm...i can't find anything on google either.. anyway thanks for you helps. Hope that @jagi can help me with this.
    jhuenges
    @jhuenges

    @jagi how would you handle errors during .save()? For example: I need to save relationships between documents of the same class. And these relationships need to be stored on both documents. So if i do somehting like

    doc1.relationships = [doc2._id];
    doc1.save();
    
    doc2.relationships = [doc1._id];
    doc2.save();

    and now something doesn't work while saving doc2, what is the easiest/best way to undo the changes?

    Sam Hulick
    @ffxsam

    question about this in the V2 docs:

    The this context in event handler is not a document. Use event.target to get a document. Use event.currentTarget to get nested document.

    does that mean if I have a Comment model that only exists as a nested object, used on Post, for example.. the event hooks in Comment have to use event.currentTarget?
    and if so, i assume event.target would refer to the parent, Post?
    Mirza Joldic
    @purplecones
    This message was deleted
    Aharon Rossano
    @aharonrossano

    Found a small issue in the documentation:
    const Visibility = Enum.create({
    name: 'Visibility',
    options: {
    PUBLIC: 0,
    PRIVATE: 1,
    INVITE_ONLY: 2
    }
    });

    'options' should be 'identifiers'

    I'm having trouble after creating my object to get the _id.
    I console.log the object and get everything except for _id.
    e.g:
    conversation = new Conversation(conv);
    console.log(conversation);
    {_id: undefined..
    Jimmy Knoot
    @jimmy1993k

    nice documented, some small things I saw while reading over it were
    var child = new Child();
    child.type; // "Child"

    var parent = new Parent();
    child.type; // "Parent"

    it should be parent.type I guess.

    birthDate: {
    type: Date,
    validators: [{
    type: 'lte',
    resolveParam: function() {
    let date = new Date();
    return date.setFullYear(date.getFullYear() - 18);
    }
    }]
    },

    I know it's just an example but you might put people on the wrong path with this one, because you're not taking into account the month and days of the year

    Joe
    @joetidee
    hi
    Anton S
    @SPAHI4
    Is this good idea to use transient field as relation? Or what is the best way?