-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update query for fetching property values and minor fixes & cleanups
- Loading branch information
Showing
4 changed files
with
80 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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', | ||
|
@@ -35,31 +42,49 @@ const newAuthor = await db.records.create('author', { | |
}); | ||
``` | ||
|
||
### Python | ||
|
||
```python | ||
newAuthor = db.records.create( | ||
"author", | ||
{ | ||
"name": "Alice Smith", | ||
"email": "[email protected]", | ||
"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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters