mongo-collection

MongoDB query to capitalise first letter in existing database

无人久伴 提交于 2019-12-02 23:06:06
问题 Here is the problem, I want to capitalise the first letter of a name in my existing database, just wanted to know if there is any query so that i can make it possbile. what i want -- in my database so many names is in unformatted ways.. like lucy, Sean, jon and so on. i want to make them in a formatted ways like. Lucy. Sean, Jon. Can anyone help me with this? Thanks in advance. 回答1: it may not be the best solution. the only hiccup in below suggestion is to get "3" of $substr:["$name1",1, 3 ]

MongoDB query to capitalise first letter in existing database

感情迁移 提交于 2019-12-02 13:10:01
Here is the problem, I want to capitalise the first letter of a name in my existing database, just wanted to know if there is any query so that i can make it possbile. what i want -- in my database so many names is in unformatted ways.. like lucy, Sean, jon and so on. i want to make them in a formatted ways like. Lucy. Sean, Jon. Can anyone help me with this? Thanks in advance. it may not be the best solution. the only hiccup in below suggestion is to get "3" of $substr:["$name1",1, 3 ] dynamically. but gives you a start? db.toupper.aggregate([{$project:{name:{$concat:[{$toUpper:{$substr:["

Can a MongoDB collection have inside it another collection?

岁酱吖の 提交于 2019-11-30 18:19:35
I need to store a recursive tree structure. A linked list. So all the objects are the same. Each has a pointer to a parent object and each has an array of child objects. Can I store such a structure in Mongo. i.e. A Mongo collection of parent objects, each object holds within it a Mongo collection of child objects. $a = $MyCollection->findOne(**some conditions)->Childs->find(...) You cant store collections in collections. But you can store ids that reference objects in other collections. You would have to resolve the id to the document or element and then if that element stores more ids you

Creating new Meteor collections on the fly

廉价感情. 提交于 2019-11-28 09:31:21
Is it possible to create new Meteor collections on-the-fly? I'd like to create foo_bar or bar_bar depending on some pathname which should be a global variable I suppose (so I can access it throughout my whole application). Something like: var prefix = window.location.pathname.replace(/^\/([^\/]*).*$/, '$1'); var Bar = new Meteor.Collection(prefix+'_bar'); The thing here is that I should get my prefix variable from URL, so if i declare it outside of if (Meteor.isClient) I get an error: ReferenceError: window is not defined . Is it possible to do something like that at all? Edit : Using the