Code Monkey home page Code Monkey logo

Comments (5)

davidebianchi avatar davidebianchi commented on July 28, 2024 1

Hi @aadamsx, I'm not sure to have understood. To make query to mongo, you should have a specific publication on meteor server. The added event on asteroid return an object with the keys collection, fields and id and include the element added to collection and not the entire collection.

You should save the collections somewhere in your application as plain JS object.

If you want to save in another structure, you can make your own mixin (like the asteroid-immutable-collections-mixin which convert the collections in Immutable.js).

from asteroid.

aadamsx avatar aadamsx commented on July 28, 2024

To make query to mongo, you should have a specific publication on meteor server

Yes, done that

The added event on asteroid return an object with the keys collection, fields and id and include the element added to collection and not the entire collection.

Yes, I've seen that, I get the following object for example:

collection: "People"
fields: Object
  createdAt: Object
  firstName: 'Test'
  lastName: 'Test'
id: "asdfWkfasedf"
msg: "added"

You should save the collections somewhere in your application as plain JS object.

OK, this is the part were I fell down. So save the object in a Session variable for example?

If you want to save in another structure, you can make your own mixin (like the asteroid-immutable-collections-mixin which convert the collections in Immutable.js).

Thank you, I'll check this out.

from asteroid.

davidebianchi avatar davidebianchi commented on July 28, 2024

OK, this is the part were I fell down. So save the object in a Session variable for example?

Yes, something like this. For example in React application we use the redux store to save the collections.

from asteroid.

aadamsx avatar aadamsx commented on July 28, 2024

For example in React application we use the redux store to save the collections.

Right, and in Blaze we use mini-mongo. So I played with this more, and it's going to be difficult doing anything with that return object, in part I guess because I don't have a redux store.

What would be great is if I could do something like what we can do with a straight DDP connection, for example. This makes it so easy to get Collections in the proper format from the remote server!

http://stackoverflow.com/a/18360441/2547360:

var remote = DDP.connect('http://server1.com/');
Items = new Meteor.Collection('items', remote); 

remote.subscribe('items', function() {
  var items = Items.find();
  console.log(items.count());  // get 1         
});

Notice how I can take the connection and pass it to the Meteor.Collection, and from there query it acts like mini-mongo on the client (with a .find())? Is there a way to do this in Asteroid?

It seems there use to be some equivalent to this before with Asteroid:

https://www.npmjs.com/package/asteroid.browser

// Connect to a Meteor backend 
var ceres = new Asteroid("localhost:3000");
 
// Use real-time collections 
ceres.subscribe("tasksPublication");
var tasks = ceres.getCollection("tasks");
tasks.insert({
  description: "Do the laundry"
});

But I can't find .getCollection()

from asteroid.

patrickcneuhaus avatar patrickcneuhaus commented on July 28, 2024

Hello guys!

I have the exact same issue as @aadamsx . Were you able to solve it?

from asteroid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.