micktaiwan/meteor-vermongo

Sample implementation on a simple form

Closed this issue ยท 7 comments

Hi Mick,

Thanks for this great package! ๐Ÿ‘

I would love to see an example implementation on a simple form, something like insert data then update this.data, then the _version thru select > option and it will automatically iterate the version number every time the document is updated, then, if a user select a certain version it displays the data of that version.

Hello,

I'll do a sample project on github when I'm back from holidays.

Take care,
Mickael.

Thats Great!

Thanks Mick! ๐Ÿ‘

Hi Mick,
I've managed to work vermongo on my apps, displaying the current version of the document but I'm having a hard time accessing older versions. I've used the provided helpers versions but only the latest version will show up on the dropdown.

Here's my code:
template

<template name="">
  Loan cycle:
  <select class='form-control'>
    {{> cycle}}
  </select>
<template name="cycle">
    {{#each versions}}
      {{> version}}
    {{/each}}
</template>

<template name="version">
  <option value="option">{{_version}}</option>
</template>

I tried this helpers but to no avail:

Template.cycle.helpers({
  versions: function() {
    var version = Enrollments.findOne(this.versionId);
    return version;
  }
});

What is the best approach to access older versions?

Thanks.

Hello,

A new collection called "Enrollments.vermongo" has been created for you.
So , as you declared

Enrollments = new Meteor.Collection('enrollments').vermongo({
  timestamps: true,
  userId: 'modifierId',
  ignoredFields: ['example']
});

You can access all versions with this collection:

EnrollmentVersions = new Meteor.Collection('enrollments.vermongo');

But more simply, the helper 'versions' shall work and give you access to all versions of an enrollment. Assuming 'cycle' represents one enrollment:

Template.cycle.helpers({
  versions: function() {
    return Enrollments.findOne(this._id).versions;
  }
});

Tell me if that works for you.

Happy development with Meteor !
Mickael.

Hi Mickael,

Thanks for your time.

I am happy developing on Meteor! ๐Ÿ‘
I tried your suggestion but to no avail, I am seeing only a blank dropdown no items.

What could be the best approach for this?

Did you publish and subscribe to your versions ?

I did a sample project here.
https://github.com/micktaiwan/scenario

Thanks for this example!

Yes, I think so, I can see the versions of the documents whenever I change something.

However, my problem is accessing older versions and loading it, in this way the user can compare the previous data versus the new data.

My use case is, loan cycle, one cycle is equivalent to an insurance claim by an enrollee.

What if an enrollee, assuming that he already claimed his insurance and decided to renew but this time with additional dependent which doesn't exist in his previous data. This is were vermongo will shine, all the previous data are kept in tact. The insurance company will know the premium of the loan based on the new declared dependent by comparing his previous data and the new data. Did i make any sense?

I've managed to display the current version of a document, I can see that the count is iterating whenever I changed and saved something on the document but I am having a hard time accessing and loading older versions.

On the example, it demonstrates displaying only the current version but not loading older versions. Maybe, tweaking the example by loading older version is great.