Mongoose Shema for Json Object

I am trying to create a mongoose schema for a json object which i will recieve from an api.
The json object has an element payMoneyid which is like this

payuMoneyId: {
    "paymentId": 1112253696,
    "splitIdMap": [{
        "amount": 10.00,
        "splitPaymentId": 1112253697,
        "merchantId": 4825051,
        "splitId": "splitId1"

I have written a schema is this how it’s supposed to be or it’s wrong?

const formSchema = new mongoose.Schema({
payuMoneyId: {
        paymentId: {
          type: Number
        splitIdMap: {
          type: Mixed

47 thoughts on “Mongoose Shema for Json Object”

Leave a Comment