mongo-collection-instances
mongo-collection-instances copied to clipboard
Maybe add the ability to give names to the local collections?
abc = new Mongo.Collection(null, { localName: 'abc' });
Mongo.Collection.getLocal('abc'); // 1
Mongo.Collection.get(null, { localName: 'abc' }); // 2
Mongo.Collection.get('abc'); // 3
Perhaps it would be necessary to add this capability. I doubt in the interface. Which of these options is more like it? How the best option to name? localName
somehow ugly.
I have the package shuttler:ref where it would be very useful.
Yeah that's a bit tricky, I'm not entirely sure of the potential use cases (we haven't had any issues crop up relating to looking up null collections so far)
so far I have 2 options:
- I will make a package
ivansglazunov:mongo-collection-instances-null
as wrapper with 3 option andname
field. - I will make pull request if you approve option
Potentially we could allow extra naming feature for both null and named collections, this may make handling multiple connections a lot more intuitive
Rather than passing in the connection, we can instead reference the name
If you specified an alternate name in the options, the main will be used?
Foo1 = new Mongo.Collection('foo', { ref: 'foo1' });
Foo2 = new Mongo.Collection('foo', { ref: 'foo2', connection: ... });
// if a 'ref' is passed in, we use that name rather than 'foo'
Mongo.Collection.get('foo1');
Mongo.Collection.get('foo2');
I think in that case, if you define null collections without a reference, we just ignore them
Mongo.Collection.get('foo'); // too ?
Should not be ignored. For example, we use custom adapter instead of DDP.
I don't think that'd be possible due to the name clash
Do you mean another connection?
Yes.
new Mongo.Collection(null, { connection: ourCustomDB });
Mongo.Collection.get(null, { connection: ourCustomDB });
In that case you would also provide a ref on instantiation just like above. Will that not work in your case?
Yes, it was cool. Only then it is not clear for what we need the second argument of the get
Hmm, can you confirm that arbitrary options make it through to addExtension
?
I think it should be alright, you will specify the ref
option for null collections, as well as any collections that are on a different connection. Perhaps Mongo.Collection.getRef('...')
is better?
That will solve this outstanding issue: https://github.com/dburles/mongo-collection-instances/issues/22
get
=> getAll
getRef
...
Not very much.
I liked the .get(name/ref: String)
Though it would be possible to overwrite a ref
if we later define a collection with the same name which may be confusing?. The advantage of using getRef
means the two are distinct.
It is a question of validation and comparison of patterns. Name conflicts can not escape. If the owner of the application knows which makes, then it is a true owner of the app :)
Exit - namespace tree :) And I think this is not the exit.
Let's go with just get
, happy for you to continue with the PR along with some tests for the new functionality
I think for backward compatibility should leave collection.
I agree, though it's not entirely working, see here: https://github.com/dburles/mongo-collection-instances/issues/22
May be because connection
must be an object with _lastSessionId
field?
Possibly. Let's continue discussion on the PR.