schema-design

MongoDB Schema Design (nested array vs separate collection)

99封情书 提交于 2020-02-24 12:17:08
问题 I'm writing client management web application. I'm trying to figure out the right way to manage my clients-payments relations. Once a day application is sending request to another API and synchronizing amount of payments for each client which I store in my database. I constantly need to run reports on payments (amount of payments) based on type of client (contract_type, sale_date and so on). I already have a clients collection. I trying to choice between two schema: { "client_id": "asdf123",

BizTalk Schema development - hexadecimal value 0x19, is an invalid character

倾然丶 夕夏残阳落幕 提交于 2020-01-30 08:18:05
问题 I have a Schema element node as below <MESSAGE>Employees eligibility for a benefit granted by a banking department agency of security.</MESSAGE> while I'm developing the schema for this node, I found the warning as warning BEC2004: '', hexadecimal value 0x19, is an invalid character. Line 20, position 26. Please could any one help me on this? 回答1: This StackOverflow question seems to be a good fit for your problem. In a nutshell, the hexadecimal character 0x19 is invalid in XML (see the Xml

Returning custom fields in MongoDB

梦想的初衷 提交于 2020-01-06 19:54:27
问题 I have a mongoDB collection with an array field that represents the lists the user is member of. user { screen_name: string listed_in: ['list1', 'list2', 'list3', ...] //Could be more than 10000 elements (I'm aware of the BSON 16MB limits) } I am using the *listed_in* field to get the members list db.user.find({'listed_in': 'list2'}); I also need to query for a specific user and know if he is member of certain lists var user1 = db.findOne({'screen_name': 'user1'}); In this case I will get the

Use more than one schema per collection on mongodb

﹥>﹥吖頭↗ 提交于 2019-12-28 05:17:09
问题 I wanted to use more than one schema per collection in mongodb , how to use it....? It gives me this error when I try to run it: Error: OverwriteModelError: Cannot overwrite allUsers model once compiled. OverwriteModelError: Cannot overwrite checkInOut model once compiled. Heres my schema.js var mongoose = require('mongoose'); var Schema = mongoose.Schema , ObjectId = Schema.ObjectId; var checkInInfoSchema= new Schema({ name:String, loginSerialId:Number }); var loginUserSchema = new Schema({

Where should I put activities timeline in mongodb, embedded in user or separately?

巧了我就是萌 提交于 2019-12-24 07:36:34
问题 I am building an e-learning app, and showing student activities as a timeline, should I embed them in the user collection, or create a separate collection with an userId . Constraints: One to many relationship. User activities are detailed and numerous For 90% of the time, we only need to see one user at an time, the other case is where a supervisor(teacher) needs to see an summary of the activities of users(maybe another collection?) I haven't thought of the use case of searching for

enforce empty JSON schema

跟風遠走 提交于 2019-12-23 09:25:01
问题 I want a JSON schema that enforces an empty JSON object, e.g. {} Is this a good idea and possible? I tried the following but it allows me to enter anything in the JSON body: { "description": "voice mail record", "type": "object", "additionalProperties": false, "properties": { } } 回答1: The answer yes this should enforce an empty schema - the validator I was using had a bug http://groups.google.co.uk/group/json-schema/browse_thread/thread/d0017b3985c8542b/106ce4afc1763eeb?hl=en&q=empty+schema

Cross-referencing foreign keys in Django 1.4

◇◆丶佛笑我妖孽 提交于 2019-12-23 03:37:08
问题 I have a Django project where I would need two models to have a foreign key to each other. However this is not possible because two Python files would have to import each other which Python doesn't allow. What is the best way to solve this problem? So my code currently looks like this: countries/models.py: from django.db.models import Model, ForeignKey from users.models import Profile class Country(Model): president = ForeignKey(Profile) users/models.py: from django.db.models import Model,

Mongodb map reduce across 2 collection

房东的猫 提交于 2019-12-22 18:15:34
问题 Let say we have user and post collection. In post collection, vote store the user name as a key. db.user.insert({name:'a', age:12}); db.user.insert({name:'b', age:12}); db.user.insert({name:'c', age:22}); db.user.insert({name:'d', age:22}); db.post.insert({Title:'Title1', vote:[a]}); db.post.insert({Title:'Title2', vote:[a,b]}); db.post.insert({Title:'Title3', vote:[a,b,c]}); db.post.insert({Title:'Title4', vote:[a,b,c,d]}); We would like to group by the post.Title and find out the count of

MongoDB data schema performance

六眼飞鱼酱① 提交于 2019-12-21 20:37:21
问题 I am trying to understand the internal allocation and placement of arrays and hashes (which, from my understanding are implemented through arrays) in MongoDB documents. In our domain we have documents with anywhere between thousands and hundreds of thousands of key-value pairs in logical groupings up to 5-6 levels deeps (think nested hashes). We represent the nesting in the keys with a dot, e.g., x.y.z , which upon insertion into MongoDB will automatically become something like: { "_id" :

MongoDB Schema Design - Real-time Chat

余生长醉 提交于 2019-12-20 08:49:53
问题 I'm starting a project which I think will be particularly suited to MongoDB due to the speed and scalability it affords. The module I'm currently interested in is to do with real-time chat. If I was to do this in a traditional RDBMS I'd split it out into: Channel (A channel has many users) User (A user has one channel but many messages) Message (A message has a user) The the purpose of this use case, I'd like to assume that there will be typically 5 channels active at one time, each handling