Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Supported version are:

| Ottoman | Nodejs | Couchbase SDK | Couchbase Server |
|---------|---------|---------------|------------------|
| ^2.0.0 | ^12.0.0 | ^4.2.0 | ^7.2.0 |
| ^2.3.0 | ^12.0.0 | ^4.4.6 | ^7.2.0 |

***Notice: make sure you are using supported versions***

Expand Down Expand Up @@ -59,9 +59,8 @@ You should see results similar to the following:
Nice Job!
```

::: tip Note
If you are using the legacy version of Ottoman, check out the [V1 docs](https://v1.ottomanjs.com/).
:::
> [!NOTE]
> If you are using the legacy version of Ottoman, check out the [V1 docs](https://v1.ottomanjs.com/).


## Ottoman v2 main goals
Expand Down Expand Up @@ -98,9 +97,8 @@ Thank you to all the people who already contributed to Couchbase Ottoman!

1. [Install Couchbase Server Using Docker](https://docs.couchbase.com/server/current/install/getting-started-docker.html).

::: tip Note
Check results on [http://localhost:8091/](http://localhost:8091/) couchbase web client.
:::
> [!TIP]
> Check results on [http://localhost:8091/](http://localhost:8091/) couchbase web client.


2. Get the repo and install dependencies
Expand Down
4 changes: 2 additions & 2 deletions docusaurus/docs/advanced/how-ottoman-works.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Using the default `keyGenerator` function that Ottoman provides and assuming you

- `User::0477024c`

::: tip Notice
:::tip Notice
This resulted key is a combination of the prefix as provided by the default `keyGenerator` function (`${metadata.modelName}`) [appended with an ID](/docs/basic/model.html#model-id) (`0477024c`).
:::

Expand Down Expand Up @@ -61,7 +61,7 @@ Let see how Ottoman handles a new document creation.

![How to Use](./create.png)

::: tip Notice
:::tip Notice
Using Ottoman you only need to think about `id` in order to execute CRUD Operations over documents.
All the `key` management will be automatically handled by Ottoman.
:::
Expand Down
32 changes: 16 additions & 16 deletions docusaurus/docs/advanced/ottoman-couchbase.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ If you are familiar with Mongoose, an ODM for MongoDB, you will feel pretty comf
In Ottoman, we have many constructs to help define schema and models at the application level. Let’s go over some of the most important terms you need to know in Ottoman.


::: tip Couchbase document example:
:::tip Couchbase document example:
```json
{
"id": 10,
Expand Down Expand Up @@ -87,7 +87,7 @@ Can use the IDE that is best to your liking and open the created directory `intr

We will start working out of the file `./createAirline.js` under the project root and add the following (based on the default configuration):

::: tip Connecting to Couchbase in Ottoman
:::tip Connecting to Couchbase in Ottoman
```js
const { Ottoman, model, Schema } = require('ottoman')

Expand Down Expand Up @@ -118,7 +118,7 @@ Creating an Ottoman `model` comprises a few things:

A `schema` defines `document` properties through an object where the key name corresponds to the property name in the `collection`.

::: tip Create an Airline Schema
:::tip Create an Airline Schema
```js
const airlineSchema = new Schema({
callsign: String,
Expand Down Expand Up @@ -146,7 +146,7 @@ The following Schema Types are permitted:

We need to call the `model` constructor on the `ottoman` instance and pass it the name of the `collection` and a reference to the `schema` definition.

::: tip Create Airline Model
:::tip Create Airline Model
```js
const Airline = ottoman.model('Airline', airlineSchema)
```
Expand All @@ -156,7 +156,7 @@ When you call the [`model()`](/docs/api/classes/ottoman.html#model) function it

Let’s also give the `airlineSchema` a ***phone number*** property. We can add a validation function that will ensure that the value is a valid phone number. Replace the `airlineSchema` section with these three blocks of code:

::: tip Add Validator to Airline Schema
:::tip Add Validator to Airline Schema
```js
const regx = /^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$/
if ( value && !value.match(regx) ) {
Expand All @@ -183,7 +183,7 @@ Validators registered with Ottoman (as we have done here with the `ottoman.addVa

There is however an easier way to validate any document properties value so long as the check you are performing uses a regular expression. The [ValidatorOption](/docs/api/interfaces/validatoroption.html#hierarchy') can take a regexp and message as an argument, so we can reduce our code down to:

::: tip Update Schema to use Validator
:::tip Update Schema to use Validator
```js
const regx = /^(\([0-9]{3}\)|[0-9]{3}-)[0-9]{3}-[0-9]{4}$/
const airlineSchema = new Schema({
Expand All @@ -205,7 +205,7 @@ Most of the basic operations are covered in our Ottoman V2 documentation, we wil

Considering the code that we already went over above that creates a `schema`, `model`, and `validators`. *Saving* a `model` and *persisting* it to the database is quite easy. Let’s create a new **Airline** `model` using our `Schema` and then *save/persist* it to the database.

::: tip Create Document & Save to Couchbase
:::tip Create Document & Save to Couchbase
```js
// Constructing our document
const cbAirlines = new Airline({
Expand Down Expand Up @@ -275,7 +275,7 @@ If we enter an invalid phone number and run node `createAirline.js` this file ag
ValidationError: Phone Number 321-321-32xx is not valid
```

::: tip Export Schema and Model
:::tip Export Schema and Model

You can define your *connection*, *schema*, and *models* in separate files, export, and use them in other files. Create a new file named `airline-schema-model.js` and move our `schema` and `model` definition to it:

Expand All @@ -300,7 +300,7 @@ exports.Airline = Airline;

Now we can create a few new files, `findAirline.js`, `updateAirline.js`, and `removeAirline.js` and populate each file with the following:

::: tip Boilerplate for Multiple Files
:::tip Boilerplate for Multiple Files
```js
const { Ottoman } = require('ottoman')
const ottoman = new Ottoman({ collectionName: '_default' });
Expand All @@ -326,7 +326,7 @@ This will help us to separate some of our code so we are not repeating it in eac

Let’s try to retrieve the record we saved to the database earlier. The [model class](/docs/api/classes/model.html) exposes several static and instance methods to perform operations on the database. We will now try to find the record that we created previously using the find method and pass the `callsign` as the search term. Let’s create a new file named `findAirline.js` and we can add the following code:

::: tip Find Airline Document by `callsign`
:::tip Find Airline Document by `callsign`
```js
// Find the Couchbase Airline document by Callsign from Couchbase Server
const findDocument = async () => {
Expand Down Expand Up @@ -367,7 +367,7 @@ Find document result:

Let’s modify the record above by finding it using the `callsign`, which we can assume that `callsign` will be a unique field in our data, then we can update the `document` all in a single operation.

::: tip Find Airline Document and Update
:::tip Find Airline Document and Update
```js
// Update the Couchbase Airline document by Callsign from Couchbase Server
const findDocumentAndUpdate = async () => {
Expand Down Expand Up @@ -416,7 +416,7 @@ _Model {

Ottoman has several methods that deal with removing documents: [remove](/docs/api/classes/document.html#remove), [removeById](/docs/api/interfaces/imodel.html#removebyid) and [removeMany](/docs/api/interfaces/imodel.html#removemany). Considering the many examples we have had so far, each of these should be very easy to understand how to use, so we will just provide a simple example here to show how to remove a `document` that we have already found using the [find](/docs/api/interfaces/imodel.html#find) method.

::: tip Remove Airline Document by ID
:::tip Remove Airline Document by ID
```js
// Remove the Couchbase Airline document by ID from Couchbase Server
const removeDocument = async () => {
Expand Down Expand Up @@ -452,7 +452,7 @@ Example of Middleware (a.k.a. [pre](/docs/basic/schema.html#register-hooks-with-

Let’s try an example by simply generating a log in the console before and after the creation (`save`) of a `document`, We are going to create a new file called `createWithHooks.js` and most of the code will look familiar except we have added `pre` and `post` hooks that will just report to us the document `name` ***pre-save*** and document `id` ***post-save***:

::: tip Create Document with Pre/Post Save Hooks
:::tip Create Document with Pre/Post Save Hooks
```js
const { Ottoman } = require('ottoman')
const ottoman = new Ottoman({ collectionName: '_default' });
Expand Down Expand Up @@ -547,7 +547,7 @@ In the next three examples, we will do the same thing using each of the three di

Let’s first create a new file named `findWithQueryBuilder.js`, and add the following code:

::: tip Find Airline Document with QueryBuilder
:::tip Find Airline Document with QueryBuilder
```js
const { Ottoman, Query } = require('ottoman')
const ottoman = new Ottoman({ collectionName: '_default' });
Expand Down Expand Up @@ -588,7 +588,7 @@ This file has a comment in the middle that says: ***“Replace with QueryBuilder

### Parameters

::: tip Demonstrate Query Builder using Parameters
:::tip Demonstrate Query Builder using Parameters
```js
const generateQuery = async () => {
try {
Expand Down Expand Up @@ -617,7 +617,7 @@ const generateQuery = async () => {

### Mixed Mode

::: tip Demonstrate Query Builder using Mixed Mode (Parameters & Access Functions)
:::tip Demonstrate Query Builder using Mixed Mode (Parameters & Access Functions)
```js
const generateQuery = async () => {
try {
Expand Down
4 changes: 2 additions & 2 deletions docusaurus/docs/advanced/ottoman.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const spaceX = await Company.findOne({name: 'Space X'});
await spaceX._populate('*')
```

::: tip
:::tip
The '_populate' function will receive 1 or many field names separate by a comma to know
the field to populate or just use the `*` wildcard to populate all references in the document,
as we showed in the above example. If you want just to populate the `ceo` field for example you
Expand Down Expand Up @@ -201,7 +201,7 @@ the result will be:

Congratulations! You retrieve the entire `Space X` data, from the nested Schemas `Company -> Person -> Address` design.

::: tip Rewriting `populateMaxDeep`
:::tip Rewriting `populateMaxDeep`
`populateMaxDeep` option is set to 1, as we can see in the previous example, but you can override it when creating the
`Ottoman` instance.

Expand Down
4 changes: 2 additions & 2 deletions docusaurus/docs/basic/ottoman.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const main = async () => {
main();
```

::: tip
:::tip
Notice we [start](/docs/api/classes/ottoman.html#start) using Ottoman without creating any instance, it's possible by using the `connect` function.
`connect` function will create a default ottoman instance with default options if there's not an ottoman default instance created yet.
:::
Expand Down Expand Up @@ -355,7 +355,7 @@ ottoman1.close();
close();
```

::: tip
:::tip
Always remember to close your connections.
:::

Expand Down
2 changes: 1 addition & 1 deletion docusaurus/docs/basic/query-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ WHERE (address IS NULL
LIMIT 20
```

::: tip Note
:::tip Note
Can also use `ignoreCase` as part of the `build` method, this will always prioritize the `$ignoreCase` value defined in clause

```ts
Expand Down
10 changes: 5 additions & 5 deletions docusaurus/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ That's it, you are ready to use Ottoman.

Supported version are:

| Ottoman | Nodejs | Couchbase SDK | Couchbase Server
| ----------- | ----------- | --------------- | -----------------
| ^2.0.0 | ^8.0.0 | ^3.2.2 | ^6.5.0
| Ottoman | Nodejs | Couchbase SDK | Couchbase Server |
|---------|---------|---------------|------------------|
| ^2.3.0 | ^12.0.0 | ^4.4.6 | ^7.2.0 |
Comment thread
ejscribner marked this conversation as resolved.

***Notice: make sure you are using supported versions***

Expand Down Expand Up @@ -64,7 +64,7 @@ You should see results similar to the following:
Nice Job!
```

::: tip Note
:::tip Note
If you are using the legacy version of Ottoman, check out the [V1 docs](https://v1.ottomanjs.com/).
:::

Expand Down Expand Up @@ -103,7 +103,7 @@ Thank you to all the people who already contributed to Couchbase Ottoman!

1. [Install Couchbase Server Using Docker](https://docs.couchbase.com/server/current/install/getting-started-docker.html).

::: tip Note
:::tip Tip
Check results on [http://localhost:8091/](http://localhost:8091/) couchbase web client.
:::

Expand Down
2 changes: 1 addition & 1 deletion docusaurus/docs/quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ node --version
npm --version
```

::: tip Note
:::tip Note
You can get to the Couchbase Server Web UI at any time by visiting [localhost:8091](http://localhost:8091/).
:::

Expand Down