Comments (4)
You don't have to supply the sub fields but rather provide the new element as a whole to be pushed into the array like so:
Collection.update(
{ _id: '1' },
{
$push: {
comments: {
userId: 'xxx',
comment: 'hello',
},
},
},
);
from meteor-collection2.
@harryadel I really appreciate your help, you just helped me achieve what I wanted, thanks A LOT
from meteor-collection2.
I don't know about c# dictionary but you may try this:
comments: { type: Array },
'comments.$': { type: Object },
'comments.$.userId': { type: String },
'comments.$.comment': { type: String }
https://github.com/aldeed/simpl-schema#schema-keys
from meteor-collection2.
@harryadel thank you for the response,
I am a little confused on the code you posted and the related code on the package,
Is the following code correct if I wanted to add values to the userId
and comment
:?
Drawings.update({_id: id}, {$push: {'comments.$.userId':Meteor.userId(), 'comments.$.comment':
document.getElementById('commentTextArea').value}}, function(error) {
if(error) {
console.log('Error : ' + error)
} else {
console.log('BINGO!!')
}
});
and will every comment be linked to the userId?
I am sorry for my newb question and I hope it is clear :)
from meteor-collection2.
Related Issues (20)
- Upsert no longer works in 3.0.5
- Duplicate key errors not correctly reporting (no Meteor.Error) HOT 3
- Migration from Meteor 1.4 to 1.9, Collection 2 from 2.10 to 3.0, SimpleSchema with meteor-collection2 error on unique option HOT 3
- Can't update the collection HOT 3
- Dynamic Schema with Validation HOT 10
- Writing a robust updatedAt autoValue HOT 4
- CONTRIBUTING.md is missing HOT 1
- Breaking change in v3.2.0 for extending schemas HOT 2
- Delete the name of collections in error messages HOT 5
- Question: A way to log all errors without actually throwing them? HOT 1
- Does not work with `$[]` positional operator HOT 1
- relplace lodash with underscore HOT 3
- FLE-Encryption HOT 3
- Expose defaultCleanOptions HOT 10
- Apply `defaultValue` on `fetch` HOT 6
- Stub exceptions are logged instead of thrown in Meteor Methods, preventing throwStubExceptions from working as intended
- Meteor 3.0 potential bug HOT 7
- 4.0 load function is not dynamic HOT 2
- Insert with 'bypassCollection2: true' throws an exception HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-collection2.