Skip to content

Conversation

teetangh
Copy link
Contributor

@teetangh teetangh commented Apr 3, 2024

No description provided.

@teetangh teetangh requested a review from a team as a code owner April 3, 2024 06:59
@teetangh teetangh requested a review from nithishr April 9, 2024 21:27
@teetangh teetangh removed the request for review from nithishr July 12, 2024 11:21
@teetangh teetangh marked this pull request as draft July 12, 2024 11:21
@teetangh teetangh self-assigned this Jun 2, 2025
@teetangh teetangh marked this pull request as ready for review June 2, 2025 09:22
@teetangh teetangh requested a review from chedim June 2, 2025 09:22
…8080 to 3000 for local application and Swagger documentation access.
…me, install additional gem, and reflect port change to 3000 for application and Swagger documentation access.

The application uses the following gems and needs to be installed globally even though they are specified in the `Gemfile`.

```shell

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use bundle install package manager not gem install for each dependency.


Once the application starts, you can see the details of the application on the logs.

![Application Startup](app_startup.png)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use relative path, so the image does not breaks in the PR


## Data Model

For this tutorial, we use three collections, `airport`, `airline` and `route` that contain sample airports, airlines and airline routes respectively. The route collection connects the airports and airlines as seen in the figure below. We use these connections in the quickstart to generate airports that are directly connected and airlines connecting to a destination airport. Note that these are just examples to highlight how you can use SQL++ queries to join the collections.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use relative path, so the image does not breaks in the PR


We have the Couchbase SDK operations defined in the `CouchbaseClient` class inside the `config/initializers/couchbase.rb` file.

We recommend creating a single Couchbase connection when your application starts up, and sharing this instance throughout your application. If you know at startup time which buckets, scopes, and collections your application will use, we recommend obtaining them from the Cluster at startup time and sharing those instances throughout your application as well.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what meant by this


We recommend creating a single Couchbase connection when your application starts up, and sharing this instance throughout your application. If you know at startup time which buckets, scopes, and collections your application will use, we recommend obtaining them from the Cluster at startup time and sharing those instances throughout your application as well.

In this application, we have created the connection object in `config/initializers/couchbase.rb` and we use this object in all of our APIs. The object is initialized in `config/initializers/couchbase.rb`. We have also stored the reference to our bucket, `travel-sample` and the scope, `inventory` in the connection object.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this line is repeated "The object is initialized in `config/initializers/couchbase.rb"

also below paragraph taks the same

Inn the above code, we first create an instance of the `Airline` class using the `update` method. We pass the ID and the airline data to the `update` method. If the airline is updated successfully, we return the airline document with a status of 200. If there are any missing fields in the request, we return a bad request status of 400. If there is any other error, we return an internal server error status of 500.

```rb
def update(id, attributes)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be consistant with create

Navigate to the `destroy` method in the `AirlinesController` class in the `airlines_controller.rb` file. We only need the airline document ID or our key from the user to delete a particular airline document using a key-value operation which is passed in the `destroy` method.

```rb
# DELETE /api/v1/airlines/{id}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be consistant with create


```rb
# GET /api/v1/airlines/list
def index

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

be consistant with create


## Running Tests

We have defined integration tests using [RSpec](https://rspec.info/) for all the API end points. The integration tests use the same database configuration as the application. For the tests, we perform the operation using the API and confirm the results by checking the documents in the database. For example, to check the creation of the document by the API, we would call the API to create the document and then read the same document directly from the database using the CouchbaseClient and compare them. After the tests, the documents are cleaned up.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just provide a single command to run all the tests , also flow other tutorials

If you would like to add another entity to the APIs, these are the steps to follow:

- Create the new entity (collection) in the Couchbase bucket. You can create the collection using the [SDK](https://docs.couchbase.com/sdk-api/couchbase-ruby-client/Couchbase/Collection.html#create_collection-instance_method) or via the [Couchbase Server interface](https://docs.couchbase.com/server/current/manage/manage-settings/manage-collections.html).
- Define the routes in a new file in the `api` folder similar to the existing routes like `airline_controller.rb`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this statement is workong properly explain where to add route, controller and model logic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants