forked from Automattic/mongoose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a6a51bd
commit be4563e
Showing
14 changed files
with
1,473 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
'use strict'; | ||
|
||
const { Array } = require('./schema/index.js'); | ||
const SchemaBigInt = require('./schema/bigint'); | ||
const SchemaBoolean = require('./schema/boolean'); | ||
const SchemaBuffer = require('./schema/buffer'); | ||
const SchemaDate = require('./schema/date'); | ||
const SchemaDecimal128 = require('./schema/decimal128'); | ||
const SchemaDouble = require('./schema/double'); | ||
const SchemaInt32 = require('./schema/int32'); | ||
const SchemaObjectId = require('./schema/objectId'); | ||
const SchemaString = require('./schema/string'); | ||
|
||
/** | ||
* Given a schema and a path to a field in the schema, this returns the | ||
* BSON type of the field, if it can be determined. This method specifically | ||
* **only** handles BSON types that are used for CSFLE and QE - any other | ||
* BSON types will return `null`. (example: MinKey and MaxKey). | ||
* | ||
* @param {import('.').Schema} schema | ||
* @param {string} path | ||
* @returns | ||
*/ | ||
function inferBSONType(schema, path) { | ||
const type = schema.path(path); | ||
|
||
if (type instanceof SchemaString) { | ||
return 'string'; | ||
} | ||
|
||
if (type instanceof SchemaInt32) { | ||
return 'int'; | ||
} | ||
|
||
if (type instanceof SchemaBigInt) { | ||
return 'long'; | ||
} | ||
|
||
if (type instanceof SchemaBoolean) { | ||
return 'bool'; | ||
} | ||
|
||
if (type instanceof SchemaDate) { | ||
return 'date'; | ||
} | ||
|
||
if (type instanceof SchemaBuffer) { | ||
return 'binData'; | ||
} | ||
|
||
if (type instanceof SchemaObjectId) { | ||
return 'objectId'; | ||
} | ||
|
||
if (type instanceof SchemaDecimal128) { | ||
return 'decimal'; | ||
} | ||
|
||
if (type instanceof SchemaDouble) { | ||
return 'double'; | ||
} | ||
|
||
if (type instanceof Array) { | ||
return 'array'; | ||
} | ||
|
||
return null; | ||
} | ||
|
||
module.exports = { | ||
inferBSONType | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,4 +146,4 @@ | |
"target": "ES2017" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,4 +51,4 @@ if [ ! -d "data" ]; then | |
echo 'Cluster Configuration Finished!' | ||
|
||
cd .. | ||
fi | ||
fi |
Oops, something went wrong.