neumino / thinky

JavaScript ORM for RethinkDB
http://justonepixel.com/thinky/
Other
1.12k stars 128 forks source link

When using batch insert, documents are not validated #330

Closed FLamparski closed 9 years ago

FLamparski commented 9 years ago

I have an array of documents xs. Stuff.insert(xs, {error: 'replace'}) inserts xs into the table, but allows invalid documents to be inserted. They then cause errors on retrieval. I'm using the current npm version of thinky.

neumino commented 9 years ago

Can you provide a script that insert non valid docs?

On Thu, Aug 27, 2015, 14:21 Filip Wieland notifications@github.com wrote:

I have an array of documents xs. Stuff.insert(xs, {error: 'replace'}) inserts xs into the table, but allows invalid documents to be inserted. They then cause errors on retrieval. I'm using the current npm version of thinky.

— Reply to this email directly or view it on GitHub https://github.com/neumino/thinky/issues/330.

neumino commented 9 years ago

Do you have asynchronous hooks?

On Thu, Aug 27, 2015, 14:28 Michel Tu orphee@gmail.com wrote:

Can you provide a script that insert non valid docs?

On Thu, Aug 27, 2015, 14:21 Filip Wieland notifications@github.com wrote:

I have an array of documents xs. Stuff.insert(xs, {error: 'replace'}) inserts xs into the table, but allows invalid documents to be inserted. They then cause errors on retrieval. I'm using the current npm version of thinky.

— Reply to this email directly or view it on GitHub https://github.com/neumino/thinky/issues/330.

FLamparski commented 9 years ago

No, I'm just defining a model schema. In particular, I'm defining a field in a nested object to be string().enum([...]), however the batch insert lets this field have a value not in the enum.

On Thu, 27 Aug 2015 at 22:30 Michel notifications@github.com wrote:

Do you have asynchronous hooks?

On Thu, Aug 27, 2015, 14:28 Michel Tu orphee@gmail.com wrote:

Can you provide a script that insert non valid docs?

On Thu, Aug 27, 2015, 14:21 Filip Wieland notifications@github.com wrote:

I have an array of documents xs. Stuff.insert(xs, {error: 'replace'}) inserts xs into the table, but allows invalid documents to be inserted. They then cause errors on retrieval. I'm using the current npm version of thinky.

— Reply to this email directly or view it on GitHub https://github.com/neumino/thinky/issues/330.

— Reply to this email directly or view it on GitHub https://github.com/neumino/thinky/issues/330#issuecomment-135560608.

neumino commented 9 years ago

insert is the ReQL command and doesn't do validation. Use Model.save or use doc.save.