Mongo handle in meteor 0.6.5+ - mongodb

In the previous version, 0.6.4, I can use Meteor._RemoteCollectionDriver.mongo.db to access to mongodb directly. Because I need to use Mongo's Grid to store files, which I cannot do easily with Meteor collections. With the new version, Meteor._RemoteCollectionDriver.mongo.db is not available anymore. Does anyone know where can I have that?
Thanks

I think they've moved to a singleton style class, see https://github.com/meteor/meteor/blob/devel/packages/mongo-livedata/remote_collection_driver.js.
Be warned this isn't upgrade proof either like before, as with all the methods beginning with _:
MongoInternals.defaultRemoteCollectionDriver

Related

Talend: How to get instance of a component in tjava

I want ask if there is way to get an instance of a component if a job (ex:tmap, tmysqlinput) in tjava code and then manipulate it manually using code?
Thank you
Very hazardous. Looking at the generated Java code will give you some answers (I think so).
In fact, accessing to some objects properties is possible (there is blogs and articles about this) but changing anything seems to be dangerous (IMHO).
TRF

MongoDB the difference between db.getCollection.find and db.tablename.find?

What is the difference between:
db.getCollection('booking').find()
and
db.booking.find()
Are they exactly the same, or when should I use which one?
db.getCollection('booking').find({_id:"0J0DR"})
db.booking.find({_id:"0J0DR"})
Yes, they are exactly the same and you can use either.
The first form db.getCollection(collectionName).find() becomes handy when your collection name contains special characters that will otherwise render the other syntax redundant.
Example:
Suppose your collection has a name that begin with _ or matches a database shell method or has a space, then you can use db.getCollection("booking trips").find() or db["booking trips"].find() where doing db.booking trips.find() is impossible.
I prefer using db.collection() to either as it will work on nonexistent collections, which is particularly useful when for example creating the first user in a users collection that doesn't yet exist.
db.collection('users').findOneAndUpdate(...) // Won't throw even if the collection doesn't exist yet
In addition to the previous answers, on the shell, they might be exactly the same but in real IDE (like PyCharm), db.getCollection(collectionName) gives you back the whole doculment even with out the find() method.

Get Collections stats in MongoDB 3.2

In earlier versions say MongoDB 2.6, the DBCollection class has this method getStats().
DBCollection.getStats()
In the new 3.x versions , we have a new class
MongoCollection
and it has no method to get the statistics.
My question is how to get the statistics from the MongoCollection class
So I think I've found a solution for you. It's a bit hackish, but from what I was reading, I couldn't find any other way around it. I was reading resources from Mongo and they were saying they simplifed the driver a bit and reduced the amount of available methods for a collection. I would guess that getStats() probably got cut since it doesn't seem like something you would do often, at least not programmatically for most use cases anyways. So here's what you can do:
First, a MongoDatabase object will have a runCommand() method. 3.0 driver docs
If you look here, you will get a list of all the commands you can execute with runCommand().
One of those commands is collStats. Based on the documentation, it looks like you will want to pass run command a Bson object that has the following form:
{
collStats: <string>,
scale: <int>,
verbose: <boolean>
}
where the collStats is the string name of the collection for which you want stats. Scale is an optional field; you can read about it at the last link. Verbose defaults to false.
I don't know for sure that this will get you want you want, but it will at least get you pretty close. Let me know how it works out!

How does Server.call work in elixir-mongo?

I'm learning Elixir and attempting to use the elixir-mongo library. During the auth/1 command, A the function uses Server.call, piping in the MongoDB request string. looking at the Mongo.Server class, it does not appear to be an actual genserver, nor have a method to match call/1. How is this working?
With high probability it doesn't work. Mongo.Server module doesn't export call function. There are no macros that generate it magically. My guess is that master branch is currently broken. If you are using the library and want to dig into the sources make sure you are looking at the same tag as the version you are using in your project.
Also, there are no classes and methods in Elixir. There are modules and functions :)

enyim and memcached : NOT_STORED errors

We are using memcached 1.2.4 via enyim and are finding it difficult to get some objects to cache. If I watch the memcache console it just says 'NOT_STORED'.
I think we need to use [serializable] but that doesnt always work. I cant find any documentation or relevant google hits.
Any one here got any clues?
Thanks
Strongly recommend upgraded your version of memcached.
NOT_STORED means just that, your data was not stored. If you are using the add command to store data, this means that there's already data under that key. If you are using replace it means that there's not data under that key. You probably mea set.
Thanks and sorry for the late reply.
The problem was two-fold. Using [Serializable] was not adequate for some objects so we have to implement ISerializable. We were also using ADD rather than SET.
From memory I couldn't find an upgrade for memcached and once we fixed the above it worked.
Cheers
I had this problem to...I was running something like:
var = CACHE.fetch("key_name",1.day,true) do
ModelName.find_by_id(id)
end
So I was having active record find a record for me but I didn't know that memcached doesn't store nil values. What was happening was active record was returning nil because it couldn't find the record and therefore I was telling memcache to store a nil value. The fix was simply this:
var = CACHE.fetch("key_name",1.day,true) do
ModelName.find_by_id(id) || ""
end
I use Ruby to code with. Hope this helps.