Skip to content

Commit a130f57

Browse files
Merge pull request #13 from ducksoop/features/12-add-multiple-fields-at-once-for-an-update
[ADD] Funtionality to Update Mutliple Fields With a Single Statement
2 parents 59cf91c + 561811e commit a130f57

File tree

5 files changed

+68
-2017
lines changed

5 files changed

+68
-2017
lines changed

QuickbaseNet/Helpers/QuickbaseCommandBuilder.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,20 @@ public RecordBuilder AddField<T>(int fieldId, T value)
125125
return this;
126126
}
127127

128+
/// <summary>
129+
/// Adds multiple fields to the record being built.
130+
/// </summary>
131+
/// <param name="fields"></param>
132+
/// <returns></returns>
133+
public RecordBuilder AddFields(params (int fieldId, dynamic value)[] fields)
134+
{
135+
foreach (var field in fields)
136+
{
137+
AddField(field.fieldId, field.value);
138+
}
139+
return this;
140+
}
141+
128142
/// <summary>
129143
/// Builds the record.
130144
/// </summary>

QuickbaseNet/QuickbaseNet.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
<PropertyGroup>
1515
<PackageId>QuickbaseNet</PackageId>
16-
<Version>1.0.1</Version>
16+
<Version>1.0.2</Version>
1717
<Authors>ducksoop</Authors>
1818
<Description>Unofficial Quickbase JSON API wrapper for .NET. Provides Query and Command builders for querying and adding/editing records.</Description>
1919
<RepositoryUrl>https://github.com/ducksoop/quickbase-net</RepositoryUrl>
2020
<RepositoryType>git</RepositoryType>
21-
<PackageReleaseNotes>Initial release; right now only have Query capabilities available.</PackageReleaseNotes>
21+
<!-- <PackageReleaseNotes>Initial release; right now only have Query capabilities available.</PackageReleaseNotes> -->
2222
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2323
<NoWarn>$(NoWarn);1591</NoWarn>
2424
<PackageLicenseExpression>MIT</PackageLicenseExpression>

README.md

Lines changed: 43 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ QuickbaseNet is a versatile C# library designed to simplify and streamline inter
66

77
## ✨ Features
88

9-
- **Fluent Interface 🌊**: Methods for building various requests easily and intuitively.
10-
- **Comprehensive CRUD Operations 🛠️**: `QuickBaseCommandBuilder` for adding new records, updating existing ones, or deleting records efficiently.
11-
- **Advanced Query Support 🔍**: `QueryBuilder` for constructing complex query requests with ease.
12-
- **Seamless Client Setup 🌐**: `QuickbaseClient` for initializing connections with realm and user token for secure and straightforward API interaction.
9+
- **Fluent Interface 🌊**: Engage with methods that allow for easy and intuitive construction of various requests.
10+
- **Comprehensive CRUD Operations 🛠️**: Use `QuickBaseCommandBuilder` to add new records, update existing ones, or delete records with efficiency.
11+
- **Enhanced Record Management 📈**: Improved `RecordBuilder` for more intuitive record modifications and additions.
12+
- **Advanced Query Support 🔍**: Leverage `QueryBuilder` to construct complex query requests effortlessly.
13+
- **Seamless Client Setup 🌐**: Initialize connections with `QuickbaseClient`, providing a secure and straightforward way to interact with the API.
1314

1415
## 💾 Installation
1516

16-
To get started with QuickbaseNet, you can install it via NuGet or clone the repository:
17+
Get started with QuickbaseNet by installing it via NuGet or cloning the repository:
1718

1819
```bash
1920
# Install via NuGet
@@ -25,96 +26,89 @@ git clone https://github.com/ducksoop/quickbase-net.git
2526

2627
## 🛠️ Usage
2728

28-
QuickbaseNet simplifies working with the QuickBase API across various operations. Here's how you can use its main features:
29+
QuickbaseNet simplifies QuickBase API interactions. Below are examples showcasing its main features:
2930

3031
### Initializing QuickbaseClient 🌟
3132

3233
```csharp
3334
// Initialize QuickbaseClient with your realm hostname and user token
3435
var quickbaseClient = new QuickbaseClient("your_realm_hostname", "your_user_token");
3536
```
37+
3638
### Handling API Responses 📬
3739

3840
#### Inserting Records
3941

4042
```csharp
41-
// Configure and build an insert request using QuickBaseCommandBuilder
43+
// Use QuickBaseCommandBuilder to configure and build an insert request
4244
var insertRequest = new QuickBaseCommandBuilder()
4345
.ForTable("your_table_id")
44-
.ReturnFields(1, 2, 3) // Specify which fields to return after the insert operation
46+
.ReturnFields(1, 2, 3)
4547
.AddNewRecord(record => record
46-
.AddField(6, "New record description") // Add data for field 6
47-
.AddField(7, 100) // Add data for field 7
48-
.AddField(9, "2024-02-13")) // Add data for field 9
48+
.AddFields(
49+
(6, "New record description"),
50+
(7, 100),
51+
(9, "2024-02-13"))
52+
)
4953
.BuildInsertUpdateCommand();
5054

51-
// Send the insert request and handle the response
55+
// Send the request and handle the response
5256
var result = await quickbaseClient.InsertRecords(insertRequest);
5357

54-
if (result.IsSuccess)
55-
{
56-
// Handle successful insert response
57-
}
58-
else
59-
{
60-
// Process the error
58+
if (result.IsSuccess) {
59+
// Success logic
60+
} else {
61+
// Error handling
6162
}
6263
```
6364

6465
#### Updating Records
6566

6667
```csharp
67-
// Configure and build an update request using QuickBaseCommandBuilder
68+
// Configure and build an update request with QuickBaseCommandBuilder
6869
var updateRequest = new QuickBaseCommandBuilder()
6970
.ForTable("your_table_id")
7071
.ReturnFields(1, 2, 3) // Specify which fields to return after the update operation
7172
.UpdateRecord(8, record => record // Specify the record to update based on its record ID (8 in this example)
7273
.AddField(7, 150) // Update field 7 with a new value
7374
.AddField(9, "2024-02-15")) // Update field 9 with a new value
74-
.BuildInsertUpdateCommand();
75+
.BuildInsertUpdateCommand(); .BuildInsertUpdateCommand();
7576

76-
// Send the update request and handle the response
77+
// Send the request and handle the response
7778
var result = await quickbaseClient.UpdateRecords(updateRequest);
7879

79-
if (result.IsSuccess)
80-
{
81-
// Handle successful update response
82-
}
83-
else
84-
{
85-
// Process the error
80+
if (result.IsSuccess) {
81+
// Success logic
82+
} else {
83+
// Error handling
8684
}
8785
```
8886

8987
#### Deleting Records
9088

9189
```csharp
92-
// Build a delete request using QuickBaseCommandBuilder
90+
// Build and send a delete request with QuickBaseCommandBuilder
9391
var deleteRequest = new QuickBaseCommandBuilder()
9492
.ForTable("your_table_id")
9593
.WithDeletionCriteria("{6.EX.'hello'}")
9694
.BuildDeleteCommand();
9795

98-
// Send the delete request and handle the response
96+
// Process the response
9997
var result = await quickbaseClient.DeleteRecords(deleteRequest);
10098

101-
if (result.IsSuccess)
102-
{
103-
// Handle successful delete response
104-
}
105-
else
106-
{
107-
// Process the error
99+
if (result.IsSuccess) {
100+
// Success logic
101+
} else {
102+
// Error handling
108103
}
109104
```
110-
##
111105

112-
### QueryBuilder - Crafting Queries with Precision 🔎
106+
### QueryBuilder - Precision in Crafting Queries 🔎
113107

114108
#### Building and Sending a Query 📤
115109

116110
```csharp
117-
// Create a query using QueryBuilder
111+
// Construct a query with QueryBuilder
118112
var query = new QueryBuilder()
119113
.From("bck7gp3q2")
120114
.Select(1, 2, 3)
@@ -124,22 +118,21 @@ var query = new QueryBuilder()
124118
.GroupBy(6, "equal-values")
125119
.Build();
126120

127-
// Send the query and handle the response
121+
// Execute the query and process the response
128122
var result = await quickbaseClient.QueryRecords(query);
129123

130-
if (result.IsSuccess)
131-
{
132-
// Process successful response
133-
}
134-
else
135-
{
136-
// Handle error
124+
if (result.IsSuccess) {
125+
// Success logic
126+
} else {
127+
// Error handling
137128
}
138129
```
139130

140131
## 👐 Contributing
141132

142-
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
133+
Contributions are
134+
135+
greatly appreciated and help make the open-source community an amazing place to learn, inspire, and create. Feel free to contribute!
143136

144137
## 📜 License
145138

0 commit comments

Comments
 (0)