Questions tagged [mongodb-schema]

MongoDB Schema is used to validate if the incoming data is valid or not.

20 questions
4
votes
2 answers

How to generate a MongoDB JSON Schema from a typescript interface?

My objective is to improve data quality in our MongoDB db - by using JSON Schema validation. We are using typescript in our project, and have interfaces for all our collections. So I'm basically looking for an effective way of; Converting this…
DauleDK
  • 3,313
  • 11
  • 55
  • 98
1
vote
0 answers

Why my document is failing my schema validation MongoDB?

Validation schema { bsonType: 'object', required: [ 'text', 'replaceLinkComponents' ], properties: { text: { bsonType: 'string', description: 'A introduction text string with replacement pattern \'${}\' that are…
1
vote
1 answer

Schema design for products and folders that contain products

I have two schemas for products and folders const ProductSchema = new Schema( { productName: String, vendor: { type: Schema.Types.ObjectId, ref: 'Vendor' }, folder: { type: Schema.Types.ObjectId, ref:…
1
vote
0 answers

How to import data from google sheets to mongodb mainly if array have to be sent?

I want to send data from google sheets to mongodb I am having a problem in sending my data mainly the array field in google sheets.I am new to this Thanks in advance. Following is my code THIS IS code.gs FILE in spreadsheet I have tried Array(word),…
1
vote
1 answer

node.js mongoose find() method usage with key value in object

I'd like to find data from mongodb using find() function Here is my schema const newcontractSchema = mongoose.Schema({ creator: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: false, index: true, }, status:…
SS-Tobi
  • 38
  • 2
  • 8
0
votes
1 answer

Why the schema of user methods does not working

When I update the password it is done. But the method used in the schema is not work. // route file route.put("/update-password", auth_middleware, update_password); // userController file const update_password = asyncHandler(async (request,…
0
votes
0 answers

Executing Schema Validation setup script is failing for a MongoDB collection

Executing Schema Validation setup script is failing for a MongoDB collection. Unable to configure the schema validator. I am trying to add a Schema Validation to a MongoDB collection and facing the following error. { "message" : "Document…
CSK 4ever
  • 45
  • 4
0
votes
1 answer

MongoDB/mongoose schema-model behaviours return undefined

In my mongodb/mongoose schema model, I set a user roles document entry like: const mongoose = require('mongoose') const {Schema} = mongoose const userSchema = new Schema({ username: {type: String, required: true}, password: {type: String,…
0
votes
1 answer

MongoDB schema validation for unknown number of attributes?

I want to save documents like this: _id: ObjectId('63fdf80e4ab6021dad4ed24b') data: { index: 1, time: 1000, dataFieldOne: 1.44 dataFieldTwo: 2.752 ... dataFieldN: 0.15 } There can be any number of dataFieldN attributes, but I want to make…
Karolis
  • 255
  • 3
  • 15
0
votes
0 answers

Mongo Atlas Data API and working with Mongoose Schemas

Hi we are looking into migrating our current mongo logic which uses mongoose schemas and the driver to conduct CRUD functions. We run this on serverless functions with many microservices that connect to the db so we have been hitting many issues…
0
votes
0 answers

mongodb schema for this specific data(contains array of objects)

I'm new to MongoDB,Can someone provide MongoDB schema for the below data : { listData : [ [ { title: 'test' } ], [ { listmessage: 'message 1' }, { listmessage: 'message 2' }, { listmessage: 'message 3' } ] …
pavan
  • 1
0
votes
1 answer

Why am I not able query ( User.findOne() ) my mongoDB after setting up a Schema?

I can't seem to query my MongoDB after setting up the MongoDB schema. I don't understand where I am going wrong with my MongoDB schema, any help is appreciated! I WAS earlier successful in querying my mongodb before creating a schema, using queries…
SirBT
  • 1,580
  • 5
  • 22
  • 51
0
votes
0 answers

Question about mongo db schema and performance

I have 2 collections all_files and trashed_files. File item object in each of these collections is the same { name, type, metadata }. Is it a good idea to create only one collection with one boolean property isTrashed in the file item object like {…
0
votes
2 answers

Is the value of `null` allowed for fields that are required?

In MongoDB, what does it mean to have the required = true condition for a field in a collection? Can the value be null?
0
votes
1 answer

How to specify that at least one field is required out of three in total?

In my MongoDB model, there are 3 fields in total. Any document added to this collection must contain at least 1 of those 3 fields. How can this be specified in the validation staged?
1
2