apache / couchdb-nano

Nano: The official Apache CouchDB library for Node.js
https://www.npmjs.com/package/nano
Apache License 2.0
651 stars 165 forks source link

Issue with `.insert`: Object literal may only specify known properties #276

Closed NetOpWibby closed 3 years ago

NetOpWibby commented 3 years ago

Expected Behavior

I should be able to insert anything into my database.

Current Behavior

I am unable to insert arbitrary data into my database for some reason.

Steps to Reproduce (for bugs)

// my code
const createResponse = await customerDatabase.insert({
  email,
  id: nanoid(),
  username: createUsername(email),
  ...CustomerDefault
});
# error in console, TS2345
Object literal may only specify known properties, and 'email' does not exist in type 'MaybeDocument | ViewDocument<unknown>'.

Your Environment

NetOpWibby commented 3 years ago

Would adding [key: string]: any; to MaybeDocument fix this?

NetOpWibby commented 3 years ago

I just discovered I can use RethinkDB on M1 Macs so I'm going back to that. However, I'm keeping this issue open for other people having the same issue.

glynnbird commented 3 years ago

Thanks for raising @NetOperatorWibby but the TypeScript usage is documented in the README https://github.com/apache/couchdb-nano#typescript

NetOpWibby commented 3 years ago

Pretty sure I was using it properly.