Skip to content

Commit

Permalink
Merge pull request #123 from rush-db/fix/support-for-min-max-date
Browse files Browse the repository at this point in the history
fix: added support for min-max date
  • Loading branch information
1pxone authored Feb 12, 2025
2 parents a0a6d09 + f703e9c commit bc0901d
Show file tree
Hide file tree
Showing 20 changed files with 298 additions and 168 deletions.
9 changes: 9 additions & 0 deletions .changeset/chilled-ways-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@rushdb/javascript-sdk': minor
'rushdb-dashboard': minor
'rushdb-core': minor
'rushdb-website': minor
'rushdb-docs': minor
---

Update query for fetching property values and minor fixes & cleanups
59 changes: 42 additions & 17 deletions docs/docs/quick-start/creating-and-retrieving-records.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,28 @@ In this section, we'll learn how to use the RushDB SDK to create and retrieve si

Ensure that you have initialized the RushDB SDK in your project as follows:

### TypeScript / Javascript
```typescript
import RushDB from '@rushdb/javascript-sdk';

const db = new RushDB('API_TOKEN');
```

### Python

```bash
from rushdb import RushDB

db = RushDB("API_TOKEN")
```

Replace `API_TOKEN` with your actual API token.

## Creating Records

The `create` method allows you to create a single record without registering a model.

### Example

Creating an author record directly:
### TypeScript / Javascript
```typescript
const newAuthor = await db.records.create('author', {
name: 'Alice Smith',
Expand All @@ -35,31 +42,49 @@ const newAuthor = await db.records.create('author', {
});
```

### Python

```python
newAuthor = db.records.create(
"author",
{
"name": "Alice Smith",
"email": "alice.smith@example.com",
"jobTitle": "writer",
"age": 28,
"married": True,
"dateOfBirth": "1993-05-15T00:00:00Z"
}
)
```


## Reading Records

The `find`, `findOne`, and `findById` methods let you read records from the database without predefining models.
The `find` method let you read records from the database without predefining models.

### Example
### TypeScript / Javascript

Finding records with specific criteria:
```typescript
const authors = await db.records.find('author', {
where: {
jobTitle: { $contains: 'writer' },
age: { $gte: 25 }
}
where: {
jobTitle: { $contains: 'writer' },
age: { $gte: 25 }
}
});
```

### Example
### Python

Finding a single record:
```typescript
const author = await db.records.findOne('author', {
where: {
email: { $contains: 'alice.smith@' }
```python
authors = db.records.find({
"labels": ["author"]
"where": {
"jobTitle": { "$contains": "writer" },
"age": { "$gte": 25 }
}
});
})
```


This simple flow demonstrates how to create and retrieve records using the RushDB SDK. By defining models and utilizing the SDK's methods, you can easily manage your application's data. Feel free to adapt these examples to fit the specific needs of your project.
32 changes: 28 additions & 4 deletions docs/docs/quick-start/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ Getting started with RushDB SDK is straightforward. This section will guide you

## Step 1: Install the Package

To begin, you need to add the RushDB SDK to your project. You can do this using either npm or yarn:
To begin, you need to add the RushDB SDK to your project.

### TypeScript / JavaScript

Using npm:

Expand All @@ -19,17 +21,39 @@ Using yarn:
yarn add @rushdb/javascript-sdk
```

### Note on SDK Size
The RushDB SDK is lightweight, coming in at just 5.1kB gzipped. Learn more about the package size [here](https://pkg-size.dev/@rushdb%2Fjavascript-sdk).
Using pnpm:
```bash
pnpm add @rushdb/javascript-sdk
```

The RushDB SDK is lightweight, coming in at just 6.9KB gzipped. Learn more about the package size [here](https://pkg-size.dev/@rushdb%2Fjavascript-sdk).

### Python

```bash
pip install rushdb
```

## Step 2: Initialize the SDK
Once the package is installed, you can create an instance of the RushDB SDK in your project.

### TypeScript / JavaScript

```typescript
import RushDB from '@rushdb/javascript-sdk';

const db = new RushDB('API_TOKEN');
```
Replace `API_TOKEN` with your actual API token, which you can obtain from the RushDB Dashboard.

### Python

```bash
from rushdb import RushDB

db = RushDB("API_TOKEN")
```

Replace `API_TOKEN` with your actual API token, which you can obtain from the [RushDB Dashboard](https://app.rushdb.com/).

## Next steps
To make full use of the SDK, you'll need a valid API token. In the [next section](/quick-start/configuring-dashboard), Configuring RushDB Dashboard, we'll guide you through the process of registering on the dashboard, creating a project, and generating your API token.
7 changes: 4 additions & 3 deletions packages/javascript-sdk/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import type {
SearchQuery,
Schema,
InferSchemaTypesWrite,
MaybeArray
MaybeArray,
PropertyValuesOptions
} from '../types/index.js'
import type { ApiResponse, RecordsApi } from './types.js'

Expand Down Expand Up @@ -428,8 +429,8 @@ export class RestAPI {
findById: async (id: string, transaction?: Transaction | string) => {
return this.api?.properties.findById(id, transaction)
},
values: async (id: string, transaction?: Transaction | string) => {
return this.api?.properties.values(id, {}, transaction)
values: async (id: string, options?: PropertyValuesOptions, transaction?: Transaction | string) => {
return this.api?.properties.values(id, options, transaction)
}
}

Expand Down
Loading

0 comments on commit bc0901d

Please sign in to comment.