Existing mongodb in a meteor project?

hey … i have need to connect my existing MONGO DB with my meteor project instant of .meteor/local/db folder . is that possible ???

Yes, simply set the MONGO_URL environment variable when running the project.

thanks mate … i’m vwey newer with meteor . can you send me any hit ??

Sorry, I’m on mobile, maybe someone else can paste a snippet.

You can do:

MONGO_URL=mongodb://yourmongoaddress meteor

or

export MONGO_URL=mongodb://yourmongoaddress
meteor

Note that when you copy your user and pw credentials, the special chars will need to be urlencoded

is that update on ~/.bash_profile ??

You should be able to stick that in a profile or bash script as necessary, yes

You can also just type that in the terminal. Then it only sets the database for the current terminal session.

this is my DB (extenal )

> show dbs
items     0.000GB
local     0.000GB
nodeauth  0.000GB
nodeblog  0.000GB
> use items
switched to db items
> show collections
items
> 

> db.items.find().pretty()
{
	"_id" : ObjectId("57e2d776282dce039fb6d3e2"),
	"title" : "this is title 00",
	"cteateAt" : ISODate("2016-09-21T18:54:46.294Z")
}
> 

i run this on terminal

channasmcs@channasmcs-Inspiron-N5110:~/Documents/Meteorss/hello_01$ MONGO_URL="mongodb://localhost:27017/items"
channasmcs@channasmcs-Inspiron-N5110:~/Documents/Meteorss/hello_01$ meteor
[[[[[ ~/Documents/Meteorss/hello_01 ]]]]]     

=> Started proxy.                             
=> Started MongoDB.                           
=> Started your app.                          

=> App running at: http://localhost:3000/

this is my DB connect meteor code

import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';

import './main.html';
//$export MONGO_URL="mongodb://localhost:27017/items";
Items =  new Mongo.Collection('items');
console.log(Items);
Template.body.helpers({
  items: function(){
  //  Items.insert({title:"this is title 04",cteateAt:new Date()});
  return Items.find();
  }
});

when i compile this is out put ( in console.log()

M…o.Collection {_transform: null, _connection: Connection, _collection: LocalCollection, _name: "items", _driver: LocalCollectionDriver…}_collection: LocalCollection_connection: Connection_driver: LocalCollectionDriver_insecure: undefined_makeNewID: ()_name: "items"_prefix: "/items/"_restricted: false_transform: null_validators: Object__proto__: Object

That will not connect to your external MongoDB. You should use one of the following:

MONGO_URL=mongodb://localhost:27017/items meteor

or

export MONGO_URL=mongodb://localhost:27017/items
meteor