Vector Search with JavaScript: example is not working

If you came to this page via a book’s portal and it has pre-filled part of the title and tags for you please only add what you need to after the pre-filled text in the title, this is usually a description of what you are posting and the page number so it follows this format:

Title: Vector Search with JavaScript
I have cloned the git repo from GitHub - hummusonrails/vector-example-blog-platform: Fully featured Medium.com clone with vector search functionality.

Unfortunately, I can not start it (on main branch):

> npm install; npm run dev
...
/Users/markus/git/vector-example-blog-platform/models/User.js:57
userModel.methods.generateAccessToken = function() {
                                      ^

TypeError: Cannot set properties of undefined (setting 'generateAccessToken')
    at Object.<anonymous> (/Users/markus/git/vector-example-blog-platform/models/User.js:57:39)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Module.require (node:internal/modules/cjs/loader:1311:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/Users/markus/git/vector-example-blog-platform/config/dbConnect.js:2:28)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)

Node.js v20.17.0
[nodemon] app crashed - waiting for file changes before starting...

Also: what version of Couchbase should I install? Is the community edition sufficient?

Thanks
Markus

1 Like

Hi Markus,

Thank you for flagging this issue! The error you encountered was due to an incorrect usage of the Ottoman schema API, but it has now been fixed in the GitHub repo, and the fix will be applied in the book as well. Your comment is very much appreciated.

To run the project and use the vectorization features, you’ll need to use Couchbase Capella (the fully managed cloud service from Couchbase), which offers a free tier and includes the vector search capabilities required by this project. The Community Edition does not support the vectorization service.

Please sign up for a free Capella account and use your connection string in the project’s configuration as shown in the .env.example file in the root folder of the GitHub repo. The book outlines the steps to connect your Capella account to your local project in detail.

All the best,

Ben

Thanks for your fast response and the fix in the repo. After creating the capella account I managed to start up the server.

It would probably save some time to other users, too, if you described some more details about the capella account and how to add the credentials:

  • create a bucket
  • allow access for IP Adress
  • create user (access control) and allow read/write on the bucket
  • copy .env.example to .env

Cheers
Markus

1 Like

Thank you, Markus. I’m glad to hear the server is working for you now. Appreciate your feedback and best of luck in your continued learning journey!