Answer the question
In order to leave comments, you need to log in
floating point number in mongoose & mongodb?
I created a user model for mongodb and ran into a problem
. I tried to create floating point values, set 0 by default, but in the console when creating a user I got:
balance: {
ref: { type: [Function: Double], default: 0 },
invest: { type: [Function: Double], default: 0 },
dep: { type: [Function: Double], default: 0 },
withdrawn: { type: [Function: Double], default: 0 }
},
const mongoose = require('mongoose')
require('mongoose-double')(mongoose);
const SchemaTypes = mongoose.Schema.Types;
const model = mongoose.model
const Schema = mongoose.Schema
const Users = model('User', new Schema({
id: Number,
name: String,
balance: {type: Object, default: {
ref: { type: SchemaTypes.Double, default: 0 },
invest: { type: SchemaTypes.Double, default: 0 },
dep: { type: SchemaTypes.Double, default: 0 },
withdrawn: { type: SchemaTypes.Double, default: 0 },
}},
ref: { type: Object, default: {
score: { type: SchemaTypes.Double, default: 0 },
refferer: Number,
}},
case: {type: String, default: ''},
admin: {type: Boolean, default: false},
lastEarn: { type: Number, default: Date.now() },
}));
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question