node-ottoman
node-ottoman copied to clipboard
Getting Started sample code does not work
If I try to run the sample code provided in the getting started section of the docs (also in the README).
const { connect, model, start, close } = require('ottoman');
const main = async () => {
await connect("couchbase://localhost/travel-sample@admin:password");
const User = model('User', { name: String });
const user = new User({ name: 'Jane Doe' });
await start();
await user.save();
console.log('Nice Job!');
await close();
}
main();
I see the following error:
TypeError: Cannot read properties of undefined (reading 'collections')
at Ottoman.get collectionManager [as collectionManager] (../node/node-ottoman/lib/ottoman/ottoman.js:173:28)
at Ottoman.<anonymous> (../node/node-ottoman/lib/ottoman/ottoman.js:389:165)
at Generator.next (<anonymous>)
at ../node/node-ottoman/lib/ottoman/ottoman.js:27:71
at new Promise (<anonymous>)
at __awaiter (../node/node-ottoman/lib/ottoman/ottoman.js:23:12)
at Ottoman.ensureCollections (../node/node-ottoman/lib/ottoman/ottoman.js:367:16)
at Ottoman.<anonymous> (../node/node-ottoman/lib/ottoman/ottoman.js:444:24)
at Generator.next (<anonymous>)
at ../node/node-ottoman/lib/ottoman/ottoman.js:27:71
However, running the sample code modeled from the couchbase docs, I do not seem to have any problems.
const { Ottoman, Schema, SearchConsistency } = require('ottoman');
const ottoman = new Ottoman();
const main = async () => {
var connection = await ottoman.connect("couchbase://localhost/travel-sample@Administrator:password");
const User = connection.model('User', { name: String });
const user = new User({ name: 'Jane Doe' });
await connection.start();
await user.save();
console.log('Nice Job!');
await ottoman.close();
}
main();
hi @thejcfactor
I already create a PR for this issue https://github.com/couchbaselabs/node-ottoman/pull/669 will be fixed in the next version.
@gsi-alejandro @thejcfactor is this worth updating on the ottoman.js docs site so its in sync with the couchbase docs page?