Skip to content

Commit

Permalink
Upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
manyuanrong committed May 14, 2020
1 parent 91e53c7 commit b451ed4
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 137 deletions.
41 changes: 17 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install rust
uses: hecrj/setup-rust-action@v1
with:
rust-version: "1.42.0"
rust-version: "1.43.0"

- name: Install clippy and rustfmt
if: matrix.kind == 'lint'
Expand All @@ -30,7 +30,7 @@ jobs:
- name: Install Deno
uses: denolib/setup-deno@master
with:
deno-version: 0.39.0
deno-version: 1.0.0

- name: Start MongoDB (MacOs)
if: matrix.kind == 'test' && startsWith(matrix.os, 'mac')
Expand Down Expand Up @@ -62,28 +62,21 @@ jobs:
rustc --version
cargo --version
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo build
uses: actions/cache@v1
with:
path: target
key: ${{ matrix.kind }}-${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
- name: Configure cargo data directory
run: echo "::set-env name=CARGO_HOME::$(pwd)/.cargo_home"

# Fix the problem that the second build of windows will fail
- name: Remove Some Cache
if: matrix.os == 'windows-2019'
run: |
rm target/release/gn_root -Recurse -ErrorAction Ignore
rm target/debug/gn_root -Recurse -ErrorAction Ignore
- name: Cache
uses: denoland/github-actions-cache@stable-prerelease
with:
path: |-
.cargo_home
target/*/.*
target/*/build
target/*/deps
key:
${{ matrix.os }}-${{ matrix.kind }}-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.kind }}-
- name: Install python
uses: actions/setup-python@v1
Expand All @@ -102,7 +95,7 @@ jobs:
run: cargo test --release --locked --all-targets
- name: Test TS
if: matrix.kind == 'test'
run: deno run -A ./test.ts
run: deno test -A --unstable ./test.ts

- name: Release
uses: softprops/action-gh-release@v1
Expand Down
36 changes: 18 additions & 18 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ edition = "2018"
crate-type = ["cdylib"]

[dependencies]
mongodb = "0.9.2"
mongodb = { version = "0.9.2" }
bson = "0.14.1"
serde_json = "1.0.50"
serde_json = "1.0.52"
serde = "1.0.106"
futures = "0.3.4"
deno_core = "0.39.0"
lazy_static = "1.4.0"
# deno = "0.29.0"
deno_core = "0.45.0"
lazy_static = "1.4.0"
2 changes: 1 addition & 1 deletion deps.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { prepare } from "https://deno.land/x/plugin_prepare@v0.3.1/mod.ts";
export { prepare } from "https://deno.land/x/plugin_prepare@v0.6.0/mod.ts";
4 changes: 2 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ export * from "./ts/database.ts";
export * from "./ts/result.ts";
export { ObjectId } from "./ts/types.ts";
export * from "./ts/util.ts";
export const VERSION = "v0.5.2";
export const RELEASE_URL = `https://github.com/manyuanrong/deno_mongo/releases/download/${VERSION}`;
export const VERSION = "v0.6.0";
export const RELEASE_URL = `https://github.com/manyuanrong/deno_mongo/releases/download/${VERSION}`;
6 changes: 3 additions & 3 deletions src/command/aggregation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct AggregationArgs {
pipeline: Vec<Value>,
}

pub fn aggregate(command: Command) -> CoreOp {
pub fn aggregate(command: Command) -> Op {
let fut = async move {
let client = command.get_client();
let data = command.data;
Expand All @@ -31,7 +31,7 @@ pub fn aggregate(command: Command) -> CoreOp {
_ => None,
})
.collect();
Ok(util::async_result(&command.args, docs))
util::async_result(&command.args, docs)
};
CoreOp::Async(fut.boxed())
Op::Async(fut.boxed())
}
8 changes: 4 additions & 4 deletions src/command/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ struct ConnectArgs {
password: Option<String>,
}

pub fn connect_with_options(command: Command) -> CoreOp {
pub fn connect_with_options(command: Command) -> Op {
let args: ConnectArgs = serde_json::from_slice(command.data.unwrap().as_ref()).unwrap();
let hosts = args
.hosts
Expand Down Expand Up @@ -56,14 +56,14 @@ pub fn connect_with_options(command: Command) -> CoreOp {
let client = mongodb::Client::with_options(options).unwrap();
let client_id: usize = NEXT_CLIENT_ID.fetch_add(1, Ordering::SeqCst);
CLIENTS.lock().unwrap().insert(client_id, client);
CoreOp::Sync(Buf::from(client_id.to_string().as_bytes()))
Op::Sync(Buf::from(client_id.to_string().as_bytes()))
}

pub fn connect_with_uri(command: Command) -> CoreOp {
pub fn connect_with_uri(command: Command) -> Op {
let uri: Vec<u8> = command.data.unwrap().as_ref().to_vec();
let uri = String::from_utf8(uri).unwrap();
let client = mongodb::Client::with_uri_str(&uri).unwrap();
let client_id: usize = NEXT_CLIENT_ID.fetch_add(1, Ordering::SeqCst);
CLIENTS.lock().unwrap().insert(client_id, client);
CoreOp::Sync(Buf::from(client_id.to_string().as_bytes()))
Op::Sync(Buf::from(client_id.to_string().as_bytes()))
}
6 changes: 3 additions & 3 deletions src/command/count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct CountArgs {
filter: Option<Value>,
}

pub fn count(command: Command) -> CoreOp {
pub fn count(command: Command) -> Op {
let fut = async move {
let client = command.get_client();
let data = command.data;
Expand All @@ -23,7 +23,7 @@ pub fn count(command: Command) -> CoreOp {
let collection = database.collection(&collection_name);

let count = collection.count_documents(filter, None).unwrap();
Ok(util::async_result(&command.args, count))
util::async_result(&command.args, count)
};
CoreOp::Async(fut.boxed())
Op::Async(fut.boxed())
}
9 changes: 3 additions & 6 deletions src/command/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct DeleteArgs {
delete_one: bool,
}

pub fn delete(command: Command) -> CoreOp {
pub fn delete(command: Command) -> Op {
let fut = async move {
let client = command.get_client();
let data = command.data;
Expand All @@ -27,10 +27,7 @@ pub fn delete(command: Command) -> CoreOp {
} else {
collection.delete_many(query, None).unwrap()
};
Ok(util::async_result(
&command.args,
delete_result.deleted_count,
))
util::async_result(&command.args, delete_result.deleted_count)
};
CoreOp::Async(fut.boxed())
Op::Async(fut.boxed())
}
8 changes: 4 additions & 4 deletions src/command/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct FindArgs {
limit: Option<i64>,
}

pub fn find(command: Command) -> CoreOp {
pub fn find(command: Command) -> Op {
let fut = async move {
let client = command.get_client();
let data = command.data;
Expand All @@ -32,7 +32,7 @@ pub fn find(command: Command) -> CoreOp {

if args.find_one {
let doc = collection.find_one(filter, None).unwrap();
Ok(util::async_result(&command.args, doc))
util::async_result(&command.args, doc)
} else {
let mut options: FindOptions = FindOptions::default();
options.skip = skip;
Expand All @@ -45,8 +45,8 @@ pub fn find(command: Command) -> CoreOp {
_ => None,
})
.collect();
Ok(util::async_result(&command.args, docs))
util::async_result(&command.args, docs)
}
};
CoreOp::Async(fut.boxed())
Op::Async(fut.boxed())
}
6 changes: 3 additions & 3 deletions src/command/indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl IndexModelArgs {
}
}

pub fn create_indexes(command: Command) -> CoreOp {
pub fn create_indexes(command: Command) -> Op {
let fut = async move {
let client = command.get_client();
let data = command.data;
Expand All @@ -48,7 +48,7 @@ pub fn create_indexes(command: Command) -> CoreOp {
let collection = database.collection(&collection_name);

let result = collection.create_indexes(models).unwrap();
Ok(util::async_result(&command.args, result))
util::async_result(&command.args, result)
};
CoreOp::Async(fut.boxed())
Op::Async(fut.boxed())
}
12 changes: 6 additions & 6 deletions src/command/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct InsertOneArgs {
doc: Value,
}

pub fn insert_one(command: Command) -> CoreOp {
pub fn insert_one(command: Command) -> Op {
let fut = async move {
let client = command.get_client();
let data = command.data;
Expand All @@ -30,12 +30,12 @@ pub fn insert_one(command: Command) -> CoreOp {
let collection = database.collection(&collection_name);

let insert_result = collection.insert_one(doc, None).unwrap();
Ok(util::async_result(&command.args, insert_result.inserted_id))
util::async_result(&command.args, insert_result.inserted_id)
};
CoreOp::Async(fut.boxed())
Op::Async(fut.boxed())
}

pub fn insert_many(command: Command) -> CoreOp {
pub fn insert_many(command: Command) -> Op {
let fut = async move {
let client = command.get_client();
let data = command.data;
Expand All @@ -54,7 +54,7 @@ pub fn insert_many(command: Command) -> CoreOp {
.map(|(_, id)| id.to_owned())
.collect();

Ok(util::async_result(&command.args, ids))
util::async_result(&command.args, ids)
};
CoreOp::Async(fut.boxed())
Op::Async(fut.boxed())
}
6 changes: 3 additions & 3 deletions src/command/list_collection_names.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::*;

pub fn list_collection_names(command: Command) -> CoreOp {
pub fn list_collection_names(command: Command) -> Op {
let fut = async move {
let client = command.get_client();
let data = command.data;
Expand All @@ -9,7 +9,7 @@ pub fn list_collection_names(command: Command) -> CoreOp {
let database = client.database(&db_name);
let collection_names = database.list_collection_names(None::<bson::Document>);

Ok(util::async_result(&command.args, collection_names.unwrap()))
util::async_result(&command.args, collection_names.unwrap())
};
CoreOp::Async(fut.boxed())
Op::Async(fut.boxed())
}
Loading

0 comments on commit b451ed4

Please sign in to comment.