These are chat archives for Automattic/mongoose

29th
Apr 2019
Syniseth
@SynthSeth
Apr 29 14:04
Any mongoose pro can tell me why {username: {unique: true}} is not working? I send multiple user account create POST requests with identical specifications and won't raise an issue.
Mile Mijatović
@mijatovicmile
Apr 29 19:43
Hello guys
I have one question about mongoose schema
@mijatovicmile
When I need to fetched some data from MongoDB
I need to define schema , mongoose schema
right ?
because I created new collection from MongoDB Compass
Collection - Places , Documents - City1, City2, City3...
Generally, I need to fetched all places in dropdown
and currently I have schema for Patients and Doctors ... and I already have places: string in the Patient schema
@mijatovicmile
Do I need to create new Schema for fetching Places in the dropdown, or can use that property separately
I have separated collection in database
http://prntscr.com/niez82
first I need to fetch all places from Places collection, and display all places as option in select dropdown
Also, I will create functionality for adding new places
when user open the select dropdown, if city does not exist, he can add it by click on the ' + ' button
when click on ' + ' button, modal window should appear, and there you can add new city
something like this
what is the better solution for organisation ?
remove place: string from Patient Mongoose Schema and create Place Mongoose Schema separately ?
and later when new patient is added, I can create relation based on ObjectId ?
What do you think, what is your suggestion ?