[06:43:47] <compeman> i have lots of models/documents in a project. each model has a customer attribute (each model is based on customer, e.g: webcontent has a customer, and other attributes)
[06:44:40] <compeman> and customer has an identity model, and identity model has contact model, and person model (for contact information and name surname bla black)
[06:45:05] <compeman> but identity model should have a customer model (e.g to separate identities for each customer).
[06:45:20] <compeman> this is the complicated one, is there any advices?
[06:48:16] <BK_man> compeman: looks like many-to-many relation to me. See here: https://www.youtube.com/watch?v=fEYYjZ7zEHc
[06:59:16] <compeman> but an identity doesn't have multi customers
[07:07:20] <BK_man> compeman: long story short: it's all dependent on your access patterns. Data structure follows your access pattern.
[07:07:43] <compeman> the problem is, customer has an identity, and identities have a customer. (one to one, it was wrong). but customer must have an identity, and identity must have a customer
[07:08:02] <compeman> i cannot create a customer without creating an identity
[07:08:29] <compeman> but identity must have a customer too. i think i have to change the structure
[07:14:31] <BK_man> compeman: I suggest thinking about data access pattern first. Will you access your data by customer or by identity?
[07:15:58] <compeman> BK_man the customers will only see their contents. and the access will be based on customer model with an authentication.
[07:17:24] <compeman> i don't save contact and personal information on customer. these are saved in other models.
[07:18:42] <compeman> e.g User has a customer. user: john is a user of ABC company
[07:21:08] <compeman> ABC Company is a company model, and this model has an identity 'XYZ'. XYZ identity has a contact model, and a customer model. I seperated those because a customer can be a Person or a Company
[07:26:30] <compeman> the unlogical thing is, e.g. ABC company has 3 officers. john,steve and kelly. john,steve and kelly are persons, and these person documents have customerID (because a customer can only see their datas). but ABC company is also an identity. For summary, i'm trying to save all datas for a projects in one database
[07:27:09] <compeman> e.g. i have 50 customers who use the same software. and want to keep in one database.
[07:27:22] <compeman> so each model has a customerId.
[07:29:12] <compeman> they will access the same API, and based on their tokens and customerIDs, they will only access their web contents
[07:30:01] <compeman> but these Customer and Identity Models are confusing. sorry for writing to many in this channel.
[13:48:10] <b0stik> hi all i have a collection on a mmap storage, i db.run command compact but i don't know how to check the state of the compact process
[14:42:31] <jr3> i have a document that has an array that be length 0 up to 128, containing objects that have an id property, is it possible to index this?
[14:42:48] <jr3> also would this be horrible to index?
[14:42:54] <cheeser> you can index that field, yes.
[14:44:23] <GothAlice> StephenLynx: You linked an… expressive and rather complete schema reference document yesterday, here's one of mine that's both code and documentation: https://gist.github.com/amcgregor/a7a8552ea1285cdc87df41e5ac1faf91?ts=4 (Obv. some things redacted ;)
[14:44:56] <StephenLynx> yeah, you said that you like auto-gen docs.
[14:45:05] <StephenLynx> I find stuff like that plain unreadable.
[14:46:23] <GothAlice> StephenLynx: If you consider that JSON is literally an object notation, defining a schema as classes with attributes is more natural to some. The end result of this is a MongoDB validation document, default set of projections, and a DAO directly compatible with Pymongo. :)
[14:47:09] <StephenLynx> it implies too much knowledge.
[14:47:21] <StephenLynx> what if the person doesn't know json, mongo
[14:47:55] <StephenLynx> not to mention that you are adding bloat with document validation.
[14:49:01] <GothAlice> That's rather a bit of argumentum ad absurdum. If the developer doesn't know and has no particular interest in knowing MongoDB, they wouldn't be using this in the first place, irrelevant. If they don't know JSON, they have some learning to do if they want to work with the web, irrelevant. Nothing is applied automatically to the DB, here, i.e. the validation document is only used if you say for it to be used, this is not Active Record,
[14:49:25] <StephenLynx> you are assuming only developers would read your documentation.
[14:50:23] <StephenLynx> if you doesn't assume any knowledge at all, your documentation reaches much more people.
[14:50:40] <StephenLynx> because you are only exposing the model and nothing else.
[14:50:40] <cheeser> that depends on who you're writing for.
[14:50:43] <GothAlice> StephenLynx: Not sure who you think the target audience of that file I gisted was, but it's not "third-party developers", and sure as heck is "only developers". That's actual model code from a closed project, not a documentation file from an open one.
[14:52:00] <StephenLynx> my docs are always for anyone interested in the project.
[14:52:06] <GothAlice> StephenLynx: It just so happens to also serve as documentation, because boy howdy, does code integrate well into programmers' editors and IDEs: http://s.webcore.io/3m0U0s3U1c2C/Screen%20Shot%202016-09-20%20at%2010.41.28.png ;P
[14:52:16] <StephenLynx> and user trying to understand the system so he can use it better or suggest a feature.
[14:53:48] <StephenLynx> and that example assumes an ODM of sorts, I guess?
[14:56:12] <GothAlice> StephenLynx: Leading question is leading. Of course it requires some support of some kind to do what it does. Which is provide an attribute access dictionary, basically. (Note the sample at the bottom having a substantially smaller number of square brackets and quotes around things to save all that JSON overhead. Functionally identical, though with some "bonus features".)
[14:57:01] <StephenLynx> yeah, i'd argue that there is no point in using an ODM with mongo on a language that has dynamic dictionaries, like python or js.
[14:57:03] <GothAlice> Specifically, this is built on marrow.mongo, which provides a Document and Field specialization for marrow.schema Container, the underlying metaclass library that does the basic "declarative" part of the schema construction.
[14:57:54] <GothAlice> StephenLynx: No point, except everything it offers that a dictionary does not, plus saving the uses of symbols, and providing all sorts of underlying machinery hooks for advanced use. I.e. the Python descriptor protocol.
[14:58:20] <GothAlice> Just because you don't grok the use of something, doesn't mean there's no point in using it.
[14:58:35] <StephenLynx> you can't do anything you couldn't already do with the db protocol.
[15:01:22] <GothAlice> Field renaming. One could roll that yourself with an enum-alike, for example have a query document like {COMPANY_FIELDS['slug']: "illico"} which results in {'s': "illico"}, which is valid Python, or, since anything worth doing twice is worth building a tool to do it for you, you could just write: Company.slug == "illico" — and you're done.
[15:02:13] <GothAlice> You failed to notice that by "field renaming" I mean having access to a field by one name, which is stored with another. But, clearly, I'll stop wasting my time.
[15:03:09] <GothAlice> StephenLynx: Again, you don't understand a reason to do that, so it's "bad code" to you instead of the solution to a problem. ¯\_(ツ)_/¯
[15:03:36] <StephenLynx> its bad code because is misleading and counter intuitive.
[15:03:49] <StephenLynx> no matter the reason, it still has those characteristics.
[15:04:16] <StephenLynx> you don't have to understand the reason for someone to drink bleach to point its a bad idea to do so.
[15:04:40] <StephenLynx> if you want to rename a field, then you rename it.
[15:05:03] <StephenLynx> might as well do a #define 1 2
[15:06:33] <GothAlice> Only because the biological interactions with bleach are universally negative, and well understood. I don't care to spend time illuminating you on why field renaming can be potentially useful, beyond "practicality beats purity", at the current time. Countering persistent arguments from ignorance is tiring, and best suited to outside of work hours.
[15:07:39] <StephenLynx> just because you don't understand the universally negative reasons of why aliasing stuff like that is bad, it doesn't mean it sn't negative.
[16:36:59] <StephenLynx> so I understand and study patterns to learn what problems they commonly solve and which general approach people suggest for them
[16:37:07] <StephenLynx> but I don't put myself on a track.
[17:03:46] <spacecrab> i just use github cuz idc and their stupid hypersensitivity shit will die eventually and whoever picks up the pieces will continue to make good features
[17:03:58] <spacecrab> where's that shrug you did earlier
[17:03:58] <StephenLynx> their link is total shit too.
[17:12:29] <StephenLynx> in the case of video and audio.
[17:13:35] <StephenLynx> I have implemented even load balancing.
[17:13:54] <StephenLynx> the software acts both as load balancer and slave.
[18:31:43] <ankurk> We are running mapReduce on a collection & saw this in db.currentOp(), "msg" : "m/r: (1/3) emit phase M/R: (1/3) Emit Progress: 0/18923 0%", Does it mean mapReduce is working?
[18:38:13] <Doyle> can you list db's with mongo --eval?
[18:46:58] <GothAlice> Anything MongoDB has a shortcut for, it actually does behind-the-scenes using command calls. https://docs.mongodb.com/manual/reference/command/listDatabases/ < there are lots of them documented. ;)
[18:47:27] <GothAlice> Anything the mongo shell has a shortcut for, that is.
[19:35:13] <spacecrab> hey GothAlice if you're around I'm curious about some replset basics
[19:35:51] <GothAlice> Ask, don't ask to ask. I'm not the only one with answers, here, and I'm not always around. (Currently at work for another 2.6 hours or so. ;)
[19:36:27] <spacecrab> sorry i was typing the next line but i have a bad habit of hitting enter before the thought is done
[19:37:14] <spacecrab> why in this file did i achieve what i was hoping to complete with rs.add(), but rs.initiate() did not? i was adding two hosts to the replica set https://github.com/gravcat/mongodb/blob/master/init-replica-set.js
[19:38:03] <spacecrab> i assumed at first that when i did the rs.initiate() block that it would add and attempt to connect to those hosts, but i actually had to run those rs.add() items to make it happen
[19:39:42] <GothAlice> No worries. Just good to keep in mind that IRC is async, so asking to ask is like a TCP SYN/SYN-ACK/ACK where such handshaking is not actually needed and only slows things down. </geeky> ;)
[19:39:55] <GothAlice> The tutorials make a point of only adding a single node during initiate, ref: https://docs.mongodb.com/manual/tutorial/deploy-replica-set/#verify-the-initial-replica-set-configuration
[19:40:33] <GothAlice> I suspect in the initiate with multiple node case it assumes they're already configured and balanced, i.e. you are attempting to recover a shard set, not actually create a new one and distribute existing data.
[19:41:03] <GothAlice> (See also the note about rs.add() possibly triggering elections. More goes on in rs.add() than you might think from rs.initiate() alone.)
[19:41:41] <GothAlice> That election bit is the bane of the existence of my mini cluster testing script. Hard to tell where the primary will actually land. ;)
[19:42:40] <spacecrab> lol nice analogy :P as for this documentation i see. so rs.initiate() sets the initial node to understand that a replica set will be used *period*, but id [1,2] in that are completely extraneous and might be more relevant to sharding
[19:43:13] <spacecrab> ill strip out the extra and leave those rs.add()'s in there but other than that cool, i wasn't *too* far off in understanding it
[19:43:15] <GothAlice> cheeser: Yeah, I'm just too lazy to add probes to my script. I just re-run it until the first node in each set is the primary like the gods intended. ;P
[19:43:48] <spacecrab> i just do a command to connect to the replica set and explicitly list the hosts, so it can send me to whichever is primary o.O
[19:44:11] <GothAlice> spacecrab: As I mentioned, I'm too lazy to get JSON parsing in BASH working. ;P
[19:44:48] <GothAlice> (Or to figure out how to get probe evals to render something BASH can more easily consume.)
[19:46:11] <GothAlice> spacecrab: But yeah, basically you need the extra work rs.add() performs to trigger chunk migrations (and possible elections ;) and such that you don't get if you bare-faced rs.initiate() with a full configuration from the get go.
[19:47:58] <jayjo> I have a bunch of documents with "_t" field that is a unix timestamp. Can I convert it to a datetime object on the whole database?
[19:48:07] <jayjo> Preferably with the shell, or something fast?
[19:48:14] <GothAlice> jayjo: Iteratively, and with bulk updates, yes.
[19:49:14] <GothAlice> I.e. you need a shell script or tiny script to iterate over the current records, convert types, then prepare a bulk update group with the field assignment updates, to be committed at the end (given enough RAM to cover the updates).
[19:52:21] <GothAlice> jayjo: One note, it may be worthwhile to check if the connection is timezone-aware. I.e. if the ISODateTime objects you convert the timestamps to know what timezone they're in, and all DB-side times should be UTC to avoid insane daylight savings calculations.
[20:09:13] <ankurk> I am getting “failed to load: /usr/local/applications/Campaigns_MR/scripts/twitter_test.js” when I run my javascript file through mongo shell, what could I do here?
[20:29:04] <jadew> hey guys, how can I convert a field to number in an aggregate query?
[20:29:26] <jadew> I'm trying to compare a field which is stored as a string to a number
[20:31:38] <Doyle> can you use mongo --eval with two rs hosts? I tried 'mongo rsname/host:port,host:port/db --eval', but got back "starting new replica set monitor for replica set rsname with seed of..."
[21:54:55] <herriojr> when upgrading a replica set, do I first upgrade the arbiter? The documentation doesn't say anything about it when upgrading
[21:55:09] <herriojr> I'm assuming I just treat it as a secondary in respect to the upgrade process
[22:12:53] <gitgud> question for mongo users. if i have a server running. and i add a replica set to it, shouldnt the replica set immediately start to fill up with a copy ?
[22:13:00] <gitgud> or is there a command i must do to trigger it?
[22:16:50] <cheeser> the sync will start automatically, yes.