Skip to content

Commit 99d0a4b

Browse files
committed
chore: Update Couchbase ORM documentation for Ruby tutorial
1 parent dc0155d commit 99d0a4b

File tree

6 files changed

+5
-207
lines changed

6 files changed

+5
-207
lines changed

docusaurus/docs/tutorial-ruby-couchbase-orm/01-introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_position: 01
44

55
# Introduction
66

7-
Welcome to the documentation for Couchbase ORM, a powerful Object-Relational Mapping (ORM) library for Ruby that simplifies interactions with Couchbase Server. This guide will walk you through the features and usage of Couchbase ORM, helping you build efficient and scalable Ruby applications with Couchbase.
7+
Welcome to the documentation for Couchbase ORM, a Object-Relational Mapping (ORM) library for Ruby that simplifies interactions with Couchbase Server. This guide will walk you through the features and usage of Couchbase ORM, helping you build efficient and scalable Ruby applications with Couchbase.
88

99
## 1.1. What is Couchbase ORM?
1010

docusaurus/docs/tutorial-ruby-couchbase-orm/04-querying.md

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,7 @@ users = User.order(age: :desc)
5555

5656
You can also chain multiple `order` clauses to sort by multiple attributes.
5757

58-
## 4.4. Limit and Offset
59-
60-
<!-- TODO: Have to implement this -->
61-
62-
To limit the number of records returned or to skip a certain number of records, you can use the `limit` and `offset` methods.
63-
64-
```ruby
65-
# Find the first 10 users
66-
users = User.limit(10)
67-
68-
# Find users starting from the 11th record
69-
users = User.offset(10)
70-
71-
# Find users starting from the 11th record and limit to 10 records
72-
users = User.offset(10).limit(10)
73-
```
74-
75-
## 4.5. Scopes
58+
## 4.4. Scopes
7659

7760
Scopes allow you to define reusable query snippets that can be chained with other query methods. Scopes are defined as class methods within your model.
7861

@@ -88,7 +71,7 @@ users = User.active.adults
8871

8972
Scopes provide a clean and DRY way to encapsulate commonly used query conditions.
9073

91-
## 4.6. Pluck
74+
## 4.5. Pluck
9275

9376
The `pluck` method allows you to retrieve specific attributes from the matched records instead of loading the entire objects. It returns an array of values for the specified attributes.
9477

@@ -100,7 +83,7 @@ names = User.pluck(:name)
10083
name_emails = User.active.pluck(:name, :email)
10184
```
10285

103-
## 4.7. Destroy All
86+
## 4.6. Destroy All
10487

10588
To delete multiple records that match specific conditions, you can use the `destroy_all` method.
10689

docusaurus/docs/tutorial-ruby-couchbase-orm/05-persistence.md

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,7 @@ user.update(name: 'John Doe', age: 30)
7171

7272
The `update` method updates only the specified attributes of the record in the database.
7373

74-
## 5.6. Atomic Operations
75-
76-
CouchbaseOrm supports atomic operations, which allow you to perform certain database operations in a single, indivisible step. Atomic operations ensure data consistency and help avoid race conditions in concurrent environments.
77-
78-
Some common atomic operations include:
79-
80-
- `increment`: Atomically increments a numeric attribute by a specified value.
81-
- `decrement`: Atomically decrements a numeric attribute by a specified value.
82-
- `append`: Atomically appends a value to a string attribute.
83-
- `prepend`: Atomically prepends a value to a string attribute.
84-
- `touch`: Updates the document's expiration time without modifying its content.
85-
86-
Here's an example of using atomic operations:
87-
88-
```ruby
89-
user = User.find('user_id_123')
90-
user.increment(:login_count)
91-
user.touch(expiry: 1.hour.from_now)
92-
```
93-
94-
In this example, the `increment` operation atomically increments the `login_count` attribute of the user, and the `touch` operation updates the document's expiration time to one hour from now.
95-
96-
## 5.7. Callbacks
74+
## 5.6. Callbacks
9775

9876
As mentioned in the previous section on defining models, CouchbaseOrm supports lifecycle callbacks that allow you to execute code at certain points in a record's persistence lifecycle.
9977

@@ -119,23 +97,3 @@ end
11997
In this example, the `encrypt_password` callback is executed before saving a user record, encrypting the password if it has been changed. The `send_welcome_email` callback is executed after creating a new user record, sending a welcome email to the user.
12098

12199
Callbacks provide a way to encapsulate and reuse common logic related to the persistence lifecycle of your records.
122-
123-
## 5.8. Transactions
124-
125-
CouchbaseOrm supports transactions, which allow you to group multiple database operations into a single, atomic unit of work. Transactions ensure that all the operations within the transaction either succeed together or fail together, maintaining data integrity.
126-
127-
```ruby
128-
CouchbaseOrm.transaction do
129-
user = User.create(name: 'John')
130-
account = Account.create(user: user, balance: 100)
131-
# ...
132-
end
133-
```
134-
135-
In this example, the creation of a user and an associated account are wrapped inside a transaction. If any operation within the transaction fails, all the changes made within the transaction will be rolled back, ensuring that the database remains in a consistent state.
136-
137-
Transactions are useful when you need to perform multiple related operations that should succeed or fail together, such as creating related records or updating multiple documents atomically.
138-
139-
That covers the basics of persistence with CouchbaseOrm. With these methods and features, you can easily create, update, delete, and manipulate records in Couchbase Server using a simple and expressive API.
140-
141-
In the next section, we'll explore the powerful associations feature of CouchbaseOrm, which allows you to define and work with relationships between your models.

docusaurus/docs/tutorial-ruby-couchbase-orm/14-advanced-topics.md

Lines changed: 0 additions & 143 deletions
This file was deleted.

docusaurus/docs/tutorial-ruby-couchbase-orm/15-troubleshooting.md renamed to docusaurus/docs/tutorial-ruby-couchbase-orm/14-troubleshooting.md

File renamed without changes.

docusaurus/docs/tutorial-ruby-couchbase-orm/16-api-reference.md renamed to docusaurus/docs/tutorial-ruby-couchbase-orm/15-api-reference.md

File renamed without changes.

0 commit comments

Comments
 (0)