couchbaselabs / node-ottoman

Node.js ODM for Couchbase
https://ottomanjs.com/
Apache License 2.0
287 stars 98 forks source link

BuildSchemaError: Unsupported type specified in the property 'strict' #714

Closed turingchangs closed 3 months ago

turingchangs commented 1 year ago

npm install ottoman

ottoman v2.3.2 BuildSchemaError: Unsupported type specified in the property 'strict'

my schema:user.js

module.exports = { options:{ scopeName: 'test', collectionName:'user' }, schema:new Schema({ id:Number, name:{type: String, required: true,}, }), };

use: model(user.options.collectionName, user.schema, user.options);

An exception occurred at this time,in lib/schema.js:BuildSchemaError: Unsupported type specified in the property 'strict'; image

I just called model() function once,but it was executed twice,and didn't get a value of Schema at the second time,

this.fields = (0, helpers_1.buildFields)(obj, strict);

and I saw an update to this file (schema.js) on github,However, the code I extracted after using the command(npm install ottoman) is not the latest 2.3.2 version

gsi-alejandro commented 1 year ago

hi @turingchangs

I was trying to reproduce your issue, but it's working correctly.

Can you try to remove your node_modules folder and the lock file (yarn, npm ,...), clean the cache, and install it again? Example using Unix command line and yarn:

rm -rf node_modules yarn.lock 
yarn cache clean
yarn install

If the issue persists please provide more information:

Note: I also check that ottoman@2.3.2 is the latest version and should be the one installed after using npm install ottoman.

Tip: We're working in a CLI to provide an easier way to get started with ottoman, it's in beta version but will be stable soon. If you want to try it proceed with these commands:

npm install -g ottoman-cli
ottoman-cli generate
// follow wizard instructions