Skip to content

Commit d7038bc

Browse files
committed
database: remove Order enum
* Remove `order` arg from `NostrDatabase::query` Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent c2232c0 commit d7038bc

File tree

21 files changed

+106
-195
lines changed

21 files changed

+106
-195
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,12 @@
130130
* database: remove `NostrDatabase::bulk_import` ([Yuki Kishimoto])
131131
* database: remove `DatabaseError::NotFound` variant ([Yuki Kishimoto])
132132
* database: remove `DatabaseError::Nostr` variant ([Yuki Kishimoto])
133+
* database: remove `Order` enum ([Yuki Kishimoto])
134+
* database: remove `order` arg from `NostrDatabase::query` ([Yuki Kishimoto])
133135
* pool: remove high latency log ([Yuki Kishimoto])
134136
* zapper: remove `Err` from `NostrZapper` and unnecessary variants from `ZapperError` ([Yuki Kishimoto])
135137
* js(nostr): remove `Keys::vanity` ([Yuki Kishimoto])
138+
* cli: remove `reverse` flag from `query` command
136139

137140
## [v0.34.0]
138141

bindings/nostr-sdk-ffi/src/database/custom.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ mod inner {
9595
use std::ops::Deref;
9696
use std::sync::Arc;
9797

98-
use nostr_sdk::database::{DatabaseError, NostrDatabase, Order};
98+
use nostr_sdk::database::{DatabaseError, NostrDatabase};
9999
use nostr_sdk::prelude::*;
100100

101101
use super::IntermediateCustomNostrDatabase;
@@ -182,11 +182,7 @@ mod inner {
182182
Ok(res as usize)
183183
}
184184

185-
async fn query(
186-
&self,
187-
filters: Vec<Filter>,
188-
_order: Order,
189-
) -> Result<Vec<Event>, DatabaseError> {
185+
async fn query(&self, filters: Vec<Filter>) -> Result<Vec<Event>, DatabaseError> {
190186
let filters = filters.into_iter().map(|f| Arc::new(f.into())).collect();
191187
let res = self
192188
.inner

bindings/nostr-sdk-ffi/src/database/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::ops::Deref;
66
use std::sync::Arc;
77

88
use nostr_ffi::{Event, EventId, Filter, PublicKey};
9-
use nostr_sdk::database::{DynNostrDatabase, IntoNostrDatabase, NostrDatabaseExt, Order};
9+
use nostr_sdk::database::{DynNostrDatabase, IntoNostrDatabase, NostrDatabaseExt};
1010
#[cfg(feature = "ndb")]
1111
use nostr_sdk::NdbDatabase;
1212
#[cfg(feature = "lmdb")]
@@ -143,7 +143,7 @@ impl NostrDatabase {
143143
.collect();
144144
Ok(self
145145
.inner
146-
.query(filters, Order::Desc)
146+
.query(filters)
147147
.await?
148148
.into_iter()
149149
.map(|e| Arc::new(e.into()))

bindings/nostr-sdk-js/src/database.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use nostr_js::event::{JsEvent, JsEventArray, JsEventId};
1111
use nostr_js::key::JsPublicKey;
1212
use nostr_js::types::JsFilter;
1313
use nostr_js::JsStringArray;
14-
use nostr_sdk::database::{DynNostrDatabase, IntoNostrDatabase, NostrDatabaseExt, Order};
14+
use nostr_sdk::database::{DynNostrDatabase, IntoNostrDatabase, NostrDatabaseExt};
1515
use nostr_sdk::WebDatabase;
1616
use wasm_bindgen::prelude::*;
1717

@@ -105,7 +105,7 @@ impl JsNostrDatabase {
105105
let filters = filters.into_iter().map(|f| f.into()).collect();
106106
Ok(self
107107
.inner
108-
.query(filters, Order::Desc)
108+
.query(filters)
109109
.await
110110
.map_err(into_err)?
111111
.into_iter()

crates/nostr-cli/src/cli/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ pub enum Command {
7676
/// Limit
7777
#[clap(short, long)]
7878
limit: Option<usize>,
79-
/// Ascending order
80-
#[clap(long)]
81-
reverse: bool,
8279
/// Query only database
8380
#[clap(long)]
8481
database: bool,

crates/nostr-cli/src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ async fn handle_command(command: Command, client: &Client) -> Result<()> {
179179
since,
180180
until,
181181
limit,
182-
reverse,
183182
database,
184183
print,
185184
json,
@@ -225,9 +224,7 @@ async fn handle_command(command: Command, client: &Client) -> Result<()> {
225224
} else if database {
226225
// Query database
227226
let now = Instant::now();
228-
let events = db
229-
.query(vec![filter], if reverse { Order::Asc } else { Order::Desc })
230-
.await?;
227+
let events = db.query(vec![filter]).await?;
231228

232229
let duration = now.elapsed();
233230
println!(

crates/nostr-database/examples/helper.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::time::Duration;
66

77
use nostr::prelude::*;
8-
use nostr_database::{DatabaseHelper, Order};
8+
use nostr_database::DatabaseHelper;
99
use tracing_subscriber::fmt::format::FmtSpan;
1010

1111
#[tokio::main]
@@ -59,15 +59,12 @@ async fn main() {
5959
}
6060

6161
let ids = index
62-
.query(
63-
vec![Filter::new()
64-
.kinds(vec![Kind::Metadata, Kind::Custom(123), Kind::TextNote])
65-
.limit(20)
66-
//.kind(Kind::Custom(123))
67-
//.identifier("myid5000")
68-
.author(keys_a.public_key())],
69-
Order::Desc,
70-
)
62+
.query(vec![Filter::new()
63+
.kinds(vec![Kind::Metadata, Kind::Custom(123), Kind::TextNote])
64+
.limit(20)
65+
//.kind(Kind::Custom(123))
66+
//.identifier("myid5000")
67+
.author(keys_a.public_key())])
7168
.await;
7269
println!("Got {} ids", ids.len());
7370

crates/nostr-database/examples/memory.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::time::Duration;
77
use nostr::prelude::*;
88
use nostr::{EventBuilder, Filter, Keys, Kind, Metadata, Tag};
99
use nostr_database::memory::MemoryDatabase;
10-
use nostr_database::{MemoryDatabaseOptions, NostrDatabase, Order};
10+
use nostr_database::{MemoryDatabaseOptions, NostrDatabase};
1111
use tracing_subscriber::fmt::format::FmtSpan;
1212

1313
#[tokio::main]
@@ -65,15 +65,12 @@ async fn main() {
6565
}
6666

6767
let events = database
68-
.query(
69-
vec![Filter::new()
70-
.kinds(vec![Kind::Metadata, Kind::Custom(123), Kind::TextNote])
71-
.limit(20)
72-
//.kind(Kind::Custom(123))
73-
//.identifier("myid5000")
74-
.author(keys_a.public_key())],
75-
Order::Desc,
76-
)
68+
.query(vec![Filter::new()
69+
.kinds(vec![Kind::Metadata, Kind::Custom(123), Kind::TextNote])
70+
.limit(20)
71+
//.kind(Kind::Custom(123))
72+
//.identifier("myid5000")
73+
.author(keys_a.public_key())])
7774
.await
7875
.unwrap();
7976
println!("Got {} events", events.len());

0 commit comments

Comments
 (0)