Skip to content

Commit df7c715

Browse files
ready for review
1 parent 05ce588 commit df7c715

File tree

11 files changed

+192
-83
lines changed

11 files changed

+192
-83
lines changed

docs/source/api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const files = [
4040
'lib/types/subdocument.js',
4141
'lib/types/arraySubdocument.js',
4242
'lib/types/buffer.js',
43-
'lib/types/decimal128.js',
43+
'lib/types/.js',
4444
'lib/types/map.js',
4545
'lib/types/array/methods/index.js'
4646
];

lib/browser.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ exports.Schema = require('./schema');
5050
* - [ObjectId](https://mongoosejs.com/docs/schematypes.html#objectids)
5151
* - [Map](https://mongoosejs.com/docs/schematypes.html#maps)
5252
* - [Subdocument](https://mongoosejs.com/docs/schematypes.html#schemas)
53+
* - Int32
5354
*
5455
* Using this exposed access to the `ObjectId` type, we can construct ids on demand.
5556
*

lib/cast/int32.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ module.exports = function castInt32(val) {
2525
const INT32_MAX = 0x7FFFFFFF;
2626
const INT32_MIN = -0x80000000;
2727

28-
let _val = Number(val);
28+
const _val = Number(val);
2929

3030
if (!isNaN(_val) && _val === Math.round(_val) && _val > INT32_MIN && _val < INT32_MAX) {
3131
return _val;
3232
}
3333
assert.ok(false);
3434
}
35-
};
35+
};

lib/mongoose.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ Mongoose.prototype.VirtualType = VirtualType;
987987
* - [ObjectId](https://mongoosejs.com/docs/schematypes.html#objectids)
988988
* - [Map](https://mongoosejs.com/docs/schematypes.html#maps)
989989
* - [Subdocument](https://mongoosejs.com/docs/schematypes.html#schemas)
990+
* - Int32
990991
*
991992
* Using this exposed access to the `ObjectId` type, we can construct ids on demand.
992993
*
@@ -1138,6 +1139,22 @@ Mongoose.prototype.syncIndexes = function(options) {
11381139

11391140
Mongoose.prototype.Decimal128 = SchemaTypes.Decimal128;
11401141

1142+
1143+
/**
1144+
* The Mongoose Int32 [SchemaType](https://mongoosejs.com/docs/schematypes.html). Used for
1145+
* declaring paths in your schema that should be 32-bit integers floating points.
1146+
* Do not use this to create a new Int32 instance, use `mongoose.Types.Int32`
1147+
* instead.
1148+
*
1149+
* #### Example:
1150+
*
1151+
* const vehicleSchema = new Schema({ numberOfCows: mongoose.Int32 });
1152+
*
1153+
* @property Decimal128
1154+
* @api public
1155+
*/
1156+
Mongoose.prototype.Int32 = SchemaTypes.Int32;
1157+
11411158
/**
11421159
* The Mongoose Mixed [SchemaType](https://mongoosejs.com/docs/schematypes.html). Used for
11431160
* declaring paths in your schema that Mongoose's change tracking, casting,

lib/query.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,7 @@ Query.prototype.getOptions = function() {
16341634
* - [projection](https://mongoosejs.com/docs/api/query.html#Query.prototype.projection())
16351635
* - sanitizeProjection
16361636
* - useBigInt64
1637+
* - promoteValues
16371638
*
16381639
* The following options are only for all operations **except** `updateOne()`, `updateMany()`, `deleteOne()`, and `deleteMany()`:
16391640
*

lib/schema.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,6 +2848,7 @@ module.exports = exports = Schema;
28482848
* - [Mixed](https://mongoosejs.com/docs/schematypes.html#mixed)
28492849
* - [UUID](https://mongoosejs.com/docs/schematypes.html#uuid)
28502850
* - [BigInt](https://mongoosejs.com/docs/schematypes.html#bigint)
2851+
* - Int32
28512852
*
28522853
* Using this exposed access to the `Mixed` SchemaType, we can use them in our schema.
28532854
*

lib/schema/bigint.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function SchemaBigInt(path, options) {
2323

2424
/**
2525
* This schema type's name, to defend against minifiers that mangle
26-
* fun
26+
* function names.
2727
*
2828
* @api public
2929
*/

lib/schema/int32.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ SchemaInt32.setters = [];
6363
/**
6464
* Attaches a getter for all Int32 instances
6565
*
66-
*
6766
* @param {Function} getter
6867
* @return {this}
6968
* @function get
@@ -76,7 +75,6 @@ SchemaInt32.get = SchemaType.get;
7675
/**
7776
* Get/set the function used to cast arbitrary values to booleans.
7877
*
79-
*
8078
* @param {Function} caster
8179
* @return {Function}
8280
* @function get
@@ -226,4 +224,4 @@ SchemaInt32.prototype._castNullish = function _castNullish(v) {
226224
* Module exports.
227225
*/
228226

229-
module.exports = SchemaInt32;
227+
module.exports = SchemaInt32;

test/bigint.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe('BigInt', function() {
3939
assert.strictEqual(doc.bigint2, 997n);
4040
});
4141

42-
it.only('handles cast errors', async function() {
42+
it('handles cast errors', async function() {
4343
const schema = new Schema({
4444
bigint: 'BigInt'
4545
});

0 commit comments

Comments
 (0)