Importing a JSON file in Meteor

There are three ways you can go about this, it depends what you’re most comfortable with & your use case. The first is to store it as a JS Object if your json data is { “name”:”bob” } you could use myjson = {“name”:”bob”} in a .js file in the /lib folder and just call … Read more

Implementing MongoDB 2.4’s full text search in a Meteor app

The simplest way without editing any Meteor code is to use your own mongodb. Your mongodb.conf should look something like this (on Arch Linux it is found at /etc/mongodb.conf) bind_ip = 127.0.0.1 quiet = true dbpath = /var/lib/mongodb logpath = /var/log/mongodb/mongod.log logappend = true setParameter = textSearchEnabled=true The key line is setParameter = textSearchEnabled=true, which, … Read more

Adding Marker to Google Maps in google-map-react

Edit: Since this answer was posted the docs (and likely, the API) of the GoogleMapReact element was changed to support children. Any child with lat and lng would be rendered at the corresponding location on the map, as also indicated by @Jobsamuel’s answer. The onGoogleApiLoaded callback should not be used for this purpose, as it … Read more

Meteor: uploading file from client to Mongo collection vs file system vs GridFS

You can achieve file uploading with Meteor without using any more packages or a third party Option 1: DDP, saving file to a mongo collection /*** client.js ***/ // asign a change event into input tag ‘change input’ : function(event,template){ var file = event.target.files[0]; //assuming 1 file only if (!file) return; var reader = new … Read more

Meteor: Calling an asynchronous function inside a Meteor.method and returning the result

Use a Future to do so. Like this: Meteor.methods({ my_function: function(arg1, arg2) { // Set up a future var fut = new Future(); // This should work for any async method setTimeout(function() { // Return the results fut.ret(message + ” (delayed for 3 seconds)”); }, 3 * 1000); // Wait for async to finish before … Read more

How do I add console.log() JavaScript logic inside of a Handlebars template?

Create a Handlebars helper in one of the client-loaded JavaScript files in your project: Template.registerHelper(“log”, function(something) { console.log(something); }); And then call it in your template: {{log someVariable}} You can log the current context with simply {{log this}}. (Note that in Meteor before version 0.8, or in pure Handlebars outside of a Meteor app, replace … Read more

Can Meteor live changes have animations?

Here is a working example of a simple animation with meteor. The situation here is that we have a list of items. If the user clicks on any of those items the item will animate 20px to the left. JS //myItem Template.myItem.rendered = function(){ var instance = this; if(Session.get(“selected_item”) === this.data._id){ Meteor.defer(function() { $(instance.firstNode).addClass(“selected”); //use … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)