I'm working through this tutorial:
https://medium.com/#matejhlavacka/6-in-6-challenge-week-1-yik-yak-web-clone-81938f3a033e
I'm unable to have the templates appear on my app, and I think I'm being held up on the two commands telling you to open a MongoDB console and type meteor mongo, and input this code:
db.yaks.insert({yak:"first yak ever"});
I've tried to download robomongo and sifted through many other resources, but still can't figure out why my page looks like below, rather than showing links:
http://wordofmouth.meteor.com/
Would appreciate any help.
Thanks all,
Eric
You probably don't have a template named "Home". The first argument after this.render is the name of the template.
Router.route('/', function () {
// 'Home' is the name of the template
this.render('Home', {
data: function () { return Items.findOne({_id: this.params._id}); }
});
});
You should have something like
<template name="Home">
</template>
Related
Sorry to ask. I'm just a noob here :(
Using Ionic 4 + Firebase, just for learning, say I have a button on html with a (click) function and want to be able to get a value!!! Banging my head on the wall!
example:
Firebase DB:
collection "Places"
doc:
id: 1
name: somename
want to click the button and by hard-coding the id, I want to alert(somename)
when I click I get [object Object], cannot get into the object.
code:
export class Tab4Page implements OnInit {
lugar: AngularFirestoreCollection<Places>;
lugares: Observable<Places[]>;
constructor(private _angFireStore: AngularFirestore) {
this.lugar = this._angFireStore.collection('Places');
this.lugares = this.lugar.valueChanges();
}
ngOnInit() { }
//this is the function
pruebaF1() {
alert(this.lugares); //What's next here???!!
}
}
sorry I can't get it.
do not know how to further dig into this.lugares to hardcode an id and just get a value: say, get nombre where id = 1, then nombre = somename
and if I say id = 2, then nombre = the name that's in the db for that doc.
not angular wise :(
Thanks in advance!!!! :)
I can see you are genuinely trying here. I see scenarios like this quite a lot and always wonder how people got this far in the first place. I'm curious, are you following a guide or just trying random bits of code?
The best thing to do is to follow some getting started tutorials which will walk you through each of the steps of the basics. Do what they want to teach you first, and then afterwards start building your own by editing bits until you find yourself writing the whole thing without problems.
This seems like an interesting guide, or the official angularfire2 docs.
Basically you are missing some concepts which would be best explained in a well written tutorial. What you get back with your code so far is an observable. That could be used in the front end with something like this:
<ul>
<li *ngFor="let item of lugares | async">
{{ item.name }} is {{ item.price }} (assuming these properties exist)
</li>
</ul>
But what you are actually asking is not this. You are writing code to access a collection, but to get a single one where id = 1 type query is a document, which would be more like:
this.placeRef = this.afs.collection(''Places'', ref => ref.where('id', '==', '1'));
But then that still gives you the missing understanding of what to do with it after. I think the best thing is to dig into the getting started documentation.
BTW the original tag you had, firebase realtime database is the old database and a very different technology, so if you are searching for information you need to make sure you are using the correct "firestore" search term.
I am reading in several places that I should be able to get the data context of the current template with Template.currentData();
I found that it seems to only work within an autorun. But after logging the data as a variable there, first it logs null, then it logs the data in the console.
When I try to use the data, like for example trying to pass data._id into a subscription, I get a TypeError in the console. TypeError: Cannot read property '_id' of null. So for some reason, the data is null and I am struggling to find out why.
I have the data context set within my routes using Iron Router:
Router.route('/stock/:stockNumber', {
name: 'stock.detail',
template: 'StockDetail',
data: function () {
return Stock.findOne({
stockNumber: this.params.stockNumber*1
});
}
});
What I am trying to do is get access to the data context so that I can pass some things from it, such as the '_id' into some other subscriptions. What am I doing wrong?
The template is otherwise correctly displaying the data on the page as expected, and I can use Spacebars to show things like {{_id}} for example. But again, I seem to be unable to get access to the data context in Template.StockDetail.onCreated
Ok, so here's what I ended up doing...
Apparently the data context is just simply not available in the onCreated, period. What I had to do was do a Collection.findOne() within the autorun to find the stockItem and set the result to a variable, then use the stockItem._id as the parameter in the new subscription IF the item was found. With both of these things, it seems to work just fine.
Template.StockDetail.onCreated(function () {
let instance = this;
instance.autorun(function () {
instance.subscribe('stock_item', Router.current().params.stockNumber);
let stockItem = Stock.findOne({ // This is what was needed for some reason...
stockNumber: Router.current().params.stockNumber*1
});
if (stockItem) { // ...and, also, this was needed
instance.subscribe('stock_item_scan_log', stockItem._id);
}
});
});
I just don't understand why I can't just easily get the _id some other way. This way just feels incorrect and I don't like it.
I try to extend autocomplete-content macro by own logic witch should be call some rest.
I finded autocomplete-content.js file where autocomplete-content is defined, but I dont have idea how to extend it by own autocompleteModule.
I tried create own JS file as resource in own add-on, but it execute before autocomplete-content.js on confluence, and autocompleteContent object was undefined.
In the end I need to have own autocomplete tool with own rest service witch will be fatch data from other DB.
If possible use AUI Select2.
Please note: AUI Select2 is based on older Select2. You have to refer to this documentation: http://select2.github.io/select2/
Something else would be to use QuickSearchDropDown
It is not really documented, but quite easy to use. Look for a file quicksearchdropdown.js in Confluence sources.
You can use it like this:
AJS.$('#myinput').quicksearch(URL_RELATIVE_TO_CONFLUENCE_BASE, false, {
makeParams: function (params) {
return {
username: params.term,
staticParam: 'blabla'
};
}
}
I'm quite new in javascript programing, so I really appreciate any help.
I'm using:
Meteor (official Windows port) latest version 1.1.0.2 with Iron Router and Autopublish package
What I'm trying to do, shouldn't be hard to do, but something is missing to me.
I just want to load data from Mongo DB collection
Movies = new Mongo.Collection('movies');
into my template in /client folder
<template name="movie_template">
<p>Dynamic page test with movieID {{id}}</p>
<h1>{{name}}</h1>
<p>{{year}}</p>
</template>
my router.js file based in /lib folder in root of my Meteor project
Router.route('/movies/:movieId', function() {
this.render('movie_template', {
waitOn: function() {
return Meteor.subscribe('moviesDetails', this.params.movieId);
},
data: function() {
return Movies.findOne({id: this.params.movieId});
}
});
});
publications.js in /server folder
Meteor.publish('movieDetails', function(movieID) {
check(movieID, Number);
return Movies.find({id: movieID});
});
Only one thing what I get is paragraph text without ID. What I'm doing wrong?
Side question:
Do I have to use publish() function while I'm using Autopublish package?
In that case just use Movies.find() instead subscribe()?
NOTE: this is my Movie object field keys.
{_id, id, name, year}
#below9k is correct and you should be using _id rather than id.
To answer your side question, with the autopublish package it is not necessary to do either Meteor.publish and Meteor.subscribe
I am using mongodb to store data and i wrote a simple js script using mongoskin to query and retrieve data from a collection and it works fine...
var db = require('mongoskin').db('winter.ceit.uq.edu.au/openbeacon');
var time = 0;
var tagid = 1101;
db.collection('set1').find({tag : {'$elemMatch': {id: tagid,name :"reader07"}}},function(err, result) {
if (err) throw err;
result.each(function(err, band) {
console.log(band.tag);
time += band.time;
});
});
However i need a way to integrate this functionality into a webpage...so say i press a button on the page, the js script runs and the queried data is displayed on the webpage. When i try using this javascript in a HTML file, it erros saying "module not found" since im referencing the index.js for mongoskin and mongodb as the source in my html file.....
Please lemme know what are the ways (preferably the simplest ways) to do this.
thank you.
Try looking for example applications
here is one
https://github.com/christkv/tic-tac-toe-steps