mongodb

What's the best way to authenticate and authorize a web and api solution like MERN Stack?

半城伤御伤魂 提交于 2021-02-11 15:19:16
问题 I'm trying to find the best way to implement authorization. At this time, only thing I need is a simple free account, but later I may include user roles for a "premium" account using a payment system like stripe. I have already started reading and experimenting with Auth0 but then found some other ways I can do it. Passport.js + MongoDB, I've seen some examples and work great but I think it is missing a way to control users, rules etc with a friendly panel (like Auth0) Using Auth0 and setting

Pymongo get inserted id's even with duplicate key error

▼魔方 西西 提交于 2021-02-11 15:15:51
问题 I am working on a flask app and using mongodb with it. In one endpoint i took csv files and inserts the content to mongodb with insert_many() . Before inserting i am creating a unique index for preventing duplication on mongodb. When there is no duplication i can reach inserted_ids for that process but when it raises duplication error i get None and i can't get inserted_ids . I am using ordered=False also. Is there any way that allows me to get inserted_ids even with duplicate key error ? def

Kubernetes(Istio) Mongodb enterprise cluster: HostUnreachable: Connection reset by peer

主宰稳场 提交于 2021-02-11 15:15:44
问题 I have Istio1.6 running in my k8 cluster. In the cluster I have also deployed sharded mongodb cluster with istio-injection disabled . And I have a different namespace for my app with istio-injection enabled . And from the pod if I try to connect to the mongo I get this connection reset by peer error : root@mongo:/# mongo "mongodb://mongo-sharded-cluster-mongos-0.mongo-service.mongodb.svc.cluster.local:27017,mongo-sharded-cluster-mongos-1.mongo-service.mongodb.svc.cluster.local:27017/?ssl

Spring boot Webservice / Microservices and scheduling

≯℡__Kan透↙ 提交于 2021-02-11 15:13:19
问题 I am having a spring boot application which exposes REST APIs and also am planning to add a spring boot scheduled task. The purpose of task is to pick up some pending 'reservations' from data store which is momgodb and process it. Now the question is when multiple instances of service running, there is high probability all the nodes will pick up same 'reservation records'. I was looking at mongodb lock for this and was checking updateAndModidy / transactions (in 4.x) of mongodb. Also

Spring boot Webservice / Microservices and scheduling

耗尽温柔 提交于 2021-02-11 15:11:41
问题 I am having a spring boot application which exposes REST APIs and also am planning to add a spring boot scheduled task. The purpose of task is to pick up some pending 'reservations' from data store which is momgodb and process it. Now the question is when multiple instances of service running, there is high probability all the nodes will pick up same 'reservation records'. I was looking at mongodb lock for this and was checking updateAndModidy / transactions (in 4.x) of mongodb. Also

Mongo Call does not remove parameters

守給你的承諾、 提交于 2021-02-11 15:06:25
问题 Im using node with mongo, and I want for the mongo get call to stop returning some values, such as _id and uid. Everything that ive read says that this call should work, but when I print the json value on my UI, it still has those values. app.get('/users', async function(req, res){ console.log("Getting User Info!"); await client.connect(); const db = client.db('database'); var uidparam = req.header("uid"); db.collection("users").findOne({"uid": uidparam}, { _id: 0, uid: 0, }, function(err,

Mongo Call does not remove parameters

假如想象 提交于 2021-02-11 15:04:22
问题 Im using node with mongo, and I want for the mongo get call to stop returning some values, such as _id and uid. Everything that ive read says that this call should work, but when I print the json value on my UI, it still has those values. app.get('/users', async function(req, res){ console.log("Getting User Info!"); await client.connect(); const db = client.db('database'); var uidparam = req.header("uid"); db.collection("users").findOne({"uid": uidparam}, { _id: 0, uid: 0, }, function(err,

My $push method in Mongoose does not work ok

孤街醉人 提交于 2021-02-11 15:02:26
问题 I have a problem understanding why $push creates only one element in nested array and shows only the id of that element const mongoose = require('mongoose'); let historySchema = new mongoose.Schema({ time: { type:String } }) //users schema let userSchema = new mongoose.Schema({ name:{ type:String, }, dob:{ type:String, }, email:{ type:String, }, noOfpeopleClimbing:{ type: Number, default:0 }, details:{ type:String, }, status:{ type: Boolean, default: false }, timeIn:{ type: Number, default: 0

How do I create a the first mongodb user with authorization enabled?

可紊 提交于 2021-02-11 14:56:39
问题 I am trying to create a admin user. I've tried several different ways. I realize that authorization is enabled , and if I turned it off, then back on it would allow me to create the first user. However I am trying to create the first user while authorization is enabled . I have wiped the data directory and I am dealing with a fresh database. I've been able to use rs.initiate() and db.createUser() from the console, but what I'm discovering is that it's impossible for me to run a script that

Using `mongoose transactions` when saving message in two collections in mongodb

我是研究僧i 提交于 2021-02-11 14:54:36
问题 If the student sends a message to the teacher, the message is saved in the teachers and students collections. The same situation is when a teacher sends a message to the student, they are also save in the two collections teachers and students . How can I apply mongoose transaction in the following code so that the message is saved in two collections.I don' want a situation that the message will be saved in one collection and in the other collection will not be saved due to an error. I am