TAPevents / tap-i18n-db

MIT License
51 stars 17 forks source link

tap-i18n-db and aldeed collection2 #21

Open arminschleicher opened 9 years ago

arminschleicher commented 9 years ago

Hey Guys, has anyone ever tried using tap-i18n-db package with collections using the collection2 package? i tried a lot of stuff but couldn't get it working...would love to see some of your sample code! thanks and cheers!

mikeifomin commented 9 years ago

@arminschleicher, what kind of problems do you have?

For me it works great together. A little trick I noticed: add field i18n to SimpleSchema

Posts = new TAPi18n.Collection('posts')

Posts.attachSchema(new SimpleSchema({

  title: {
     type: String,
  }

  // all translations is inside this field
  i18n: {
    type: Object,
    // important for skip validation
    blackbox: true,
    optional: true
  }

}

But it code has some danger side effects! Any "hacker" :) can save to i18n filed any structure and overwrite document, so before updateTranslations function we need to validate data manually.

Can some one tell better solution?

samuelluis commented 8 years ago

I have a similar code, but doesn't work, the insertTranslations function returns null and doesn't insert anything.