1.1.2 • Published 3 years ago

node-mongoogle v1.1.2

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

Create service account

  1. Create a service account: https://console.developers.google.com/iam-admin/serviceaccounts/
  2. In options, create a key: this key is your usual client_secret.json - use it the same way
  3. Make the role owner for the service account (Member name = service account ID = service account email ex: thomasapp@appname-201813.iam.gserviceaccount.com
  4. Copy the email address of your service account = service account ID
  5. Simply go in your browser to the Google sheet you want to interact with
  6. Go to SHARE on the top right of your screen
  7. Go to advanced settings and share it with an email address of your service account ex: thomasapp@appname-201813.iam.gserviceaccount.com

Usage

const credentials = {
  private_key: "",
  client_email: "",
};

const testSheet = async () => {
  const db = new Mongoogle({ dsn: "mongodb://127.0.0.1:27017", credentials });
  const collection = await db.sheet(
    "1ZhqrUJx_tp1MLfpHdptkW-0wAVbgXhB41Kyvak8JHfs:COMMENTS",
    true
  );
  const list = await collection.find({}).toArray();
  console.log(list);
};

const testDoc = async () => {
  const db = new Mongoogle({ dsn: "mongodb://127.0.0.1:27017", credentials });
  const doc = await db.doc(
    "1r82ml0wf5Xv3VTxNpQzBoLMtZ5Q2153VbY7bD5focPI",
    true
  );
  console.log(doc);
};

Scope manage

https://developers.google.com/identity/protocols/oauth2/scopes

only support sheets、docs、drive

1.1.1

3 years ago

1.1.0

3 years ago

1.1.2

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago